|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Populate Input Box from Listbox?
Can anyone demonstrate or point me in the right direction as to how to populate a single input box, with a single selection from a listbox?
I can't seem to find any examples of this. Thanks in advance for your help. |
|
#2
|
||||
|
||||
|
How about something like this?
Code:
<html>
<head>
<title>Test Page</title>
</head>
<body>
<h1>Test Page</h1>
<form>
<select onchange="document.getElementById('txtInput').value=this.opt ions[this.selectedIndex].value;">
<option>Hello</option>
<option>World</option>
</select>
<input id="txtInput" type="text">
<input type="submit" value="Go">
</form>
</body>
</html>
|
|
#3
|
|||
|
|||
|
Working example of populated input field
Thanks MadCowDzz,
I used this code to display the country code for a telephone number. The user selects their country and then this populates a disabled text field with the country code value. This is the code for the populated field: Code:
<input type="text" id="ccode" name="telephone_code" class="shortfield" size="3" disabled /> And this is the code for the select menu that populates the field: Code:
<select id="country" name="country" class="text" onchange="document.getElementById('ccode').value=this.option s[this.selectedIndex].value;">
You can see the select and input working here: http://www.kualalumpurcondo.com/enquiry This is a good way to get the full country code when you are dealing with enquiries from all over the world. |
|
#4
|
||||
|
||||
|
You may want to look at this example:
http://ehsan.bdwebwork.com/blog?a=d&b=48&s=8 |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Populate Input Box from Listbox? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|