cfselect onchange or onselect to populate a field via Access dbase query
Posted on 2005-05-10
I'm creating a form that has a dropdown of items to order and I need the price associated with this item to populate the price field. The dropdown is a cfselect populated with options from an Access database (the prices are here too). I want the onchange or onselect to query the same database and populate the price field with the price associated with the hardware selected. There are four dropdowns on the same page that need the same functionality.
Here a portion of the code that I have so far; I removed my poor attempts at adding in the onchange or onselect. I think that these events need to hit a second page with the query, passing through the hardware selected as the condition in the query and pass that price back through to the main page (or I'm just babbling).
<cfquery name="hardware" datasource="mydatabase">
WHERE type IN ('hardware', 'none')
ORDER BY description
<cfform action="form.cfm" method="post" name="proposal" id="proposal">
<td><cfselect name="hardware" size="1" query="hardware" display="description" value="part_number" selected="none"></cfselect></td>
<td><input type="text" name="hardware_qty" size="3" value="1"></td>
<td><input type="hidden" name="hardware_price" value="#hardware_price#"><font face="arial" size="2"><b> $#hardware_price#</b></font></td>
Thank you in advance for any help provided,