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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hidden field to be populated from either text or drop-down 1

Status
Not open for further replies.

vjh

Technical User
Dec 14, 2002
46
CA
hello all,

I have three fields - one text, one drop-down and one hidden, all dynamically generated through JSP. I would like to have the hidden field be populated by either the text value or the drop-down value input by the user.


<input type = 'text' size=5 name = 'IDt'>
<select name = 'IDs'><options....>etc.
<input type = 'hidden' name = 'ID' value = ???>

Actually, there are sets of these 3 fields, the number of
which is determined by a certain condition, so I need to also dynamically generate the validation script.

Is javascript the best option for this? Or is there an better way?

Thanks for any suggestions!

vj
 
here's one way:

<input type='text' size=5 name='IDt' onchange=&quot;this.form.ID.value = this.value;&quot;/>
<select name='IDs' onchange=&quot;this.form.ID.value = this[this.selectedIndex].value&quot;>
<option value=&quot;someValue&quot;>
</select>
<input type='hidden' name='ID'/>


as for a dynamic number of these groups, you'll have to have some naming convention to differentiate, like:

<input type='text' size=5 name='IDt1' onchange=&quot;this.form.ID1.value = this.value;&quot;/>
<select name='IDs1' onchange=&quot;this.form.ID1.value = this[this.selectedIndex].value&quot;>
<option value=&quot;someValue&quot;>
</select>
<input type='hidden' name='ID1'/>

...

<input type='text' size=5 name='IDt2' onchange=&quot;this.form.ID2.value = this.value;&quot;/>
<select name='IDs2' onchange=&quot;this.form.ID2.value = this[this.selectedIndex].value&quot;>
<option value=&quot;someValue&quot;>
</select>
<input type='hidden' name='ID2'/>



=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
Thanks Jeff,

It worked the first try. (Or at least once I got all the
typos out of my code.)

v
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top