Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating three fields from one select tag

Status
Not open for further replies.

programmher

Programmer
May 25, 2000
235
US
I have a select box that reflects three variables (car make, car model, and car year).

How do I update the text field associated with the values once they have been selected from the drop-down select tag?

EX: <select name=&quot;change_car_type&quot;> (the values are Ford Thunderbird 1976)

My other code is just a list of cfinput text input fields.

This is sooooo simple. What am I missing?!?!?

 
&quot;How do I update the text field associated with the values once they have been selected from the drop-down select tag?&quot;
?? what do you want to do ?? give an example please ! or perform a search on this forum as i think this qustion's already been answered
 
Iza,

I want three separate text fields on my form to automatically update when the user selects the corresponding value from one drop down select box. The three fields are on different places on my site. The select box reflects all three values at the same time

I have searched this forum on several key words, but did not locate an answer to my specific question - similar; but nothing that resolved my question. The closest I found was updating multiple fields on different pages. My modificatons of this suggestion did not work.

 
This is really a JS question. You'll want to use the &quot;onchange()&quot; event for the select box and just use it to set the three text boxes like this.

<script>
function changeVals()
document.f1.text1.value=f1.s1.options[f1.s1.selectedindex].value;
document.f1.text2.value=f1.s1.options[f1.s1.selectedindex].value;
document.f1.text3.value=f1.s1.options[f1.s1.selectedindex].value;
</script>

<form name=&quot;f1&quot;>
<select name =&quot;s1&quot; onchange=&quot;changeVals();&quot;>

The only problem is that you'll have to use some JS string handling functions to strip out the separate values from the drop down entry. My example will update all three fields with the same string. I would try the JS forums for help with the string handling.

GJ
 
GJ is right, but i think you can handle strings with cfm - especially if the text boxes are NOT on the same page - but don't forget this very important thing : cf is SERVER side whereas js is CLIENT side
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top