Login | |
|
 |
Populate info on form from db dynamically - 4/13/2005 8:08:48 PM
|
|
 |
|
| |
awieds
Posts: 2
Score: 0
Joined: 4/13/2005
From:
Status: offline
|
I have a database. One table is a list of products and other tables have info about the products. I have a page with a combobox where the user selects a product. The I have blank fields where the user will be able to fill out info about the products and append the db. What I'd like is that when the user selects a product the fields will populate with the data already in the database so the user sees what is currently there and he can change it. My combobox populates fin with the products but I am having trouble with the second part. OnChange for my menu I cann a sub and it's not eben going into the sub! I will post my code: [code] <% dim rs dim strQuery dim i dim numRecords dim arrProducts() dim MySubmittedVariable i=0 Set rs = Server.CreateObject("ADODB.Recordset") strQuery="Select * from products order by productname" rs.Open strQuery, MM_myConn_STRING, 3, 2 ,1 numRecords=rs.recordcount redim arrProducts(numRecords,1) while not rs.eof arrProducts(i,0)=rs("productname") arrProducts(i,1)=rs("productid") i=i+1 rs.movenext wend rs.close() function DescTest() msgbox "testing" reponse.write "testing2" dim desRS dim strSelect dim strDescription mySubmittedVariable=document.selectFrm.Products.value Set desrs = Server.CreateObject("ADODB.Recordset") strSelect="Select description from productdescription where productid= " & mySubmittedVariable desrs.Open strSelect, MM_myConn_STRING, 3, 2 ,1 strDescription=desRS("description") document.desfrm.txtDescription.value =strDescription msgbox "testing" msgbox(document.desfrm.txtDescription.value) rs.close() 'response.Redirect("changetext.asp?" & strDescription) end function set rs=nothing %> </head> <body> <table> <tr> <td>Please select the product you'd like to change:</td> <form action="SelectProduct.asp" method="post" name="SelectFrm"> <td><select name="Products" id="products" onChange= "DescTest()"> <%dim j for j=lbound(arrproducts) to ubound(arrproducts)-1%> <option value=<%=arrproducts(j,1)%>> <%=arrproducts(j,0)%></option> <% next %> </select></td> </form> </tr> <tr> <td>Please enter a description of the product:</td> <td> </td> </tr> <tr> <td> </td> <td><textarea name="txtDescription" cols="65" rows="9"></textarea></td> </tr></table> [\code]
|
|
| |
|
|
|
|
|