Current location: Hot Scripts Forums » General Web Coding » JavaScript » Javascript select populates text input?


Javascript select populates text input?

Reply
  #1 (permalink)  
Old 03-01-08, 12:46 PM
hinch hinch is offline
Wannabe Coder
 
Join Date: Oct 2004
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
Javascript select populates text input?

Hi there,

I'm looking for a script that allows me to use a drop down select box filled with links that when chosen sends the link to a text input.

Something like...
HTML Code:
<select>
 <option value="http://link">Link 1</option>
 <option value="http://link">Link 1</option>
 <option value="http://link">Link 1</option>
</select>
<button>Choose</button>
When the 'choose' button was clicked it would send the link value to a text box.

Any ideas? I've taken a look at a few combo boxes but really the only way to format is as above, to the keep code to a minimum.

Last edited by Nico; 03-01-08 at 12:58 PM.
Reply With Quote
  #2 (permalink)  
Old 03-01-08, 12:58 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Even though this is a script request, I think in this case you're better off here in the Javascript section, since this is just a small task.

javascript Code:
  1. <script type="text/javascript">
  2. function put_link()
  3. {
  4.     document.getElementById('chosen_link').value = document.getElementById('links').value;
  5. }
  6. </script>

HTML Code:
<select id="links">
<option value="http://link">Link 1</option>
<option value="http://link">Link 1</option>
<option value="http://link">Link 1</option>
</select>
<button onclick="put_value();">Choose</button>
<input type="text" id="chosen_link" />
Reply With Quote
  #3 (permalink)  
Old 03-02-08, 06:13 AM
hinch hinch is offline
Wannabe Coder
 
Join Date: Oct 2004
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
That's great, thanks!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
text box with scroll bar silvermane CSS 7 01-16-09 03:03 AM
auto select all text within an input value ? triplebig JavaScript 7 01-06-08 08:35 PM
Draggable Tables Ares JavaScript 10 08-03-06 06:55 AM
Need Your HelP! Loading Multiple External Text into Multiple Dynamic Text Fields Flash_Boi Flash & ActionScript 2 03-30-06 03:27 PM
picking random entries with a filter... Double selection problem dsumpter PHP 7 11-16-03 07:19 PM


All times are GMT -5. The time now is 11:37 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.