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!

Automatically Populate a Text Box

Status
Not open for further replies.

khurram

IS-IT--Management
Jan 10, 2001
95
CA
I am trying to have a customer select from a drop down and whatever value is in it, populate a text box on the same form. Is this possible and if so, how?

Thanks
 
Hey khurram,

Is this what you're looking for?

<form name=&quot;f1&quot;>
<select name=&quot;s1&quot; onchange=&quot;document.f1.t1.value=this[this.selectedIndex].value;&quot;>
<option value=&quot;a&quot;>a
<option value=&quot;b&quot;>b
</select>
<input type=&quot;text&quot; name=&quot;t1&quot;>
</form>

GJ
 
This works fine. How can make it so that both the 'value' of the drop down and the 'display' will populate two different text boxes?
 
I can't find any reference on how you separate the label from the value. From what I can tell, JS only allows you to retrieve what is specified in the &quot;value=&quot; attribute. You could do a little trickery though and use a delimiter and put both in there like this:

<option value=&quot;5,Page 1&quot;>Page 1
<option value=&quot;6,Page 2&quot;>Page 2

You could then write JS to separate them on the client side and use the CF list functions to separate them on the server side. That's the only way I can see right now to retrieve both the value and the label from with client side JS.

GJ
 
Is this what you mean:

<form name=&quot;f1&quot;>
<select name=&quot;s1&quot; onchange=&quot;document.f1.t1.value=this[this.selectedIndex].value; document.f1.t2.value=this[this.selectedIndex].text;&quot;>
<option value=&quot;a&quot;>Option A
<option value=&quot;b&quot;>Option B
</select>
<input type=&quot;text&quot; name=&quot;t1&quot;><br>
<input type=&quot;text&quot; name=&quot;t2&quot;>
</form>

Diplay can be referred to by &quot;text&quot;, value by &quot;value&quot; (makes sense doesn't it ;-) )
Hope this helps... <webguru>iqof188</webguru>
 
Thanks IQ, I couldn't find that in any of my references including the O'Reilly JS book.

GJ
 
Gj : it's in the devedge and the msdn on line doc ;-)
 
..and of course inside IQ's head! :)

<webguru>iqof188</webguru>
 
i'm looking forward to seeing your head on line ;-) (that would b great !)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top