Forum Moderators: phranque

Message Too Old, No Replies

Linked listbox.

Connecting prices to items

         

Tracy

11:37 am on Nov 5, 2002 (gmt 0)

10+ Year Member



I have a list box which is linked to a database and retrieves a list of items. I want to link this to a text box which will show the corresponding price for the selected item.

This is the code I have from Dreamweaver so far which populates the list box with a list of materials from the database. (It is an Access database).

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/lrm.asp" -->
<%
set materials = Server.CreateObject("ADODB.Recordset")
materials.ActiveConnection = MM_lrm_STRING
materials.Source = "SELECT * FROM Materials"
materials.CursorType = 0
materials.CursorLocation = 2
materials.LockType = 3
materials.Open()
materials_numRows = 0
%>
<snip...>
<select name="select">
<%
While (NOT materials.EOF)
%>
<option value="<%=(materials.Fields.Item("Cost").Value)%>" ><%=(materials.Fields.Item("Materials").Value)%></option>
<%
materials.MoveNext()
Wend
If (materials.CursorType > 0) Then
materials.MoveFirst
Else
materials.Requery
End If
%>
</select>
<snip...>
<%
materials.Close()
%>

Any help is very much appreciated/

Tracy

edit reason: please don't post so much code that is not related to the issue. Thanks![\1]

[1][edited by: txbakers at 1:11 pm (utc) on Nov. 5, 2002]

BlobFisk

1:14 pm on Nov 5, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Tracy and welcome to WebMasterWorld!

Am I correct in saying that you would like to populate a text box with the price of the item selected in the drop down list?

If use the DOM to change the value attribute of the text box. You would then use the onChange method in the <option> field.

That is, you would dynamically write your <option> using ASP and then onChange="textbox.value='{Price retrieved from database}';".

Hope this helps!

<added> You would also need to add more ASP to retrieve the item price from the database too. </added>