Time:
Scotland: Fri, 10:29 pm
Rhode Island: Fri, 5:29 pm
Florida: Fri, 5:29 pm
New Mexico: Fri, 3:29 pm
California: Fri, 2:29 pm

Click here to visit Livelife365.com

Click here to visit nmdarts.com



Buy this Ad Space.

180px wide.

Please get in touch with KH@ if you are interested and make an offer.

CLICK HERE TO GET AUCTION BAR NOW
US$10 per year - Save $100s!
The Fabulously Unfair
WebX Auction Bar. For Ebay etc.
Ro-Sham-Bo the opposition. Laugh like Eric Cartman when you win! CLICK HERE NOW!


More information and sign-up.

WebXpertz Hosting.
Custom fit from $5pm. PHP/MySQL
You'll save money, we'll save money. Seems fair to me. Interested? If so Please PM me here and tell me what you need. Thanks!


Please click here for more information

For continued disscussion on this topic : Filling edit field based on drop down menu selection


rwrona
05-05-2004, 02:43 PM
Can anyone point me to a reference that I can use to populate the contents of an edit field or even a static text field based on a selection in a drop down menu? I have a list of codes people can choose from. Once they select the code and click the seach button, I want to display the explanatory text for them in a field on the same page.

Any help would be very much appreciated.

Thanks!

diades
05-05-2004, 03:47 PM
Hi rwrona

Welcome to the City!:)
To gather the selected value from a select you need to access the options collection and find, from that, which the user selected. To do that us:
object.options[object.selectedIndex].value
you can use this in the onchange event-handler for the select thus:
<select onchange="myText.value = this.options[this.selectedIndex].value">
<option value="a">A</option>
<option value="b">B</option>
<option value="c">C</option>
<option value="d">D</option>
</select>
<input name="mytext" type="text" />

KH@
05-08-2004, 08:20 PM
javascript???

then,,, or like this maybe ??? If you want help to appear on the same page as the form.

<form>


<select name="whatever" onChange="document.getElementById('message').innerHTML=this.value;">
<option value="0">pick one</option>
<option value="you selected do this">Do This</option>
<option value="you selected do that">Do That</option>
</select>

</form>

<div id="message">
da Message
</div>

Note my JavaScript is not good. Daides is a much better bet :D

Coldfusion If you want help to appear on the same page as the search results

If you want to submit the form info to a processing page then display the help message on that then you could use a switch.

Say the select box name was "whatever" as above, and the values of the options were a, b, c etc. Then on the processing page you could test the value passed and display the appropriate text.


<cfswitch expression="#whatever#">

<cfcase value="a"><p>You picked A</p></cfcase>

<cfcase value="b"><p>You picked B</p></cfcase>

<cfcase value="c"><p>You picked C</p></cfcase>

</cfswitch>

Note using CFSWICH/CFCASE is a better option than CFIF CFELSEIF and CFELSE as the switch jumps out of the loop imediately it finds a match (thus saving a few serverside milliseconds) whereas CFIF etc will test all IF IFELSE statements before it continues