Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Populate info on form from db dynamically

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,2681
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> Populate info on form from db dynamically
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 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]
 
 
Post #: 1
 
 Re: Populate info on form from db dynamically - 4/14/2005 3:13:50 AM   
  VBS

 

Posts: 110
Score: 0
Joined: 3/2/2005
From: Lebanon
Status: offline
Dear awieds,
U can do what u want in a simple way, which will use less lines than u used, try this code, it does exactly the same as u want:


      

Please note that this has not been tested cause i am away from my pc, and i don't have an IIS on this PC to test it

Hope this helps


Best Regards

Firas S Assaad

(in reply to awieds)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> Populate info on form from db dynamically Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts