Link to home
Start Free TrialLog in
Avatar of Northumberland
Northumberland

asked on

Database Record

I have a query with Microsoft Frontpage because I am trying to learn HTML and ASP.

I have a list box on a web page that gets its values from a table called dbo_PRODUCT and a field called PRODUCTCODE.  When I publish the asp page it displays a list of the codes in that field.

What I dont know how to do is this :

The dbo_product table has columns of :

PRODUCTCODE      DESCRIPTION

I want to create a text box, so when the user selects a code from the productcode list the text box populates itself with the description.


Also I want to create a text box where the user can enter feedback.  I then want them to click a button called Save which will add the record to a table called Comments which has fields of PRODUCTCODE and COMMENTS.  So I want to be able to tell the form to add the record and use the PROUCTCODE that was selected in the list.

Can someone please help me through my learning curve ?  
Avatar of Northumberland
Northumberland

ASKER

Does anybody know the answer to this ?
Northumberland You posted the same question under Dreamweaver,
Did you to try to Follow those instructions?
If I understand your question, here's how I propogate a drop down list from a database field.  First, I set up the sub routine:

'this sub requires that the data connection be established first (DataConn)
Sub drop_down_list(field_name,table_name)

sql_dropdown = ("SELECT DISTINCT " & field_name & " FROM " & table_name & " WHERE " & field_name & " <> '' ORDER BY " & field_name)
Set rs_dropdown = Server.CreateObject("ADODB.Recordset")
rs_dropdown.Open sql_dropdown, DataConn
response.write("<select name=" & field_name & " size='1'>")
response.write("<option value='0' selected>Select from list</option>")
rs_dropdown.MoveFirst
While Not rs_dropdown.EOF
      field_value = rs_dropdown(field_name)
      response.write("<option value='" & field_value & "'>" & field_value & "</option>")
      rs_dropdown.MoveNext
Wend
response.write("</select>")
rs_dropdown.Close
Set rs_dropdown = Nothing

End Sub
%>

Then wherever I want the drop down to appear, I only need:

<%call drop_down_list("field","table")%>
ASKER CERTIFIED SOLUTION
Avatar of hhammash
hhammash

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial