Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-04-2010, 12:55 PM   PM User | #1
Anishgiri
Regular Coder

 
Join Date: May 2010
Posts: 173
Thanks: 0
Thanked 0 Times in 0 Posts
Anishgiri is an unknown quantity at this point
How to put select value on input box

I am trying but I can't figure it out, let say you select something on your select values, after selecting that value, how can you dynamically put that value on an input box?
Anishgiri is offline   Reply With Quote
Old 12-04-2010, 01:26 PM   PM User | #2
vwphillips
Senior Coder

 
Join Date: Mar 2005
Location: Portsmouth UK
Posts: 4,355
Thanks: 3
Thanked 458 Times in 445 Posts
vwphillips is a jewel in the roughvwphillips is a jewel in the roughvwphillips is a jewel in the rough
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
  <title></title>
<script type="text/javascript">
/*<![CDATA[*/

function TextBox(sel,nme){
 sel.form[nme].value=sel.value;
}
/*]]>*/
</script></head>

<body>
<form>
<select name="select" size="1" onchange="TextBox(this,'textbox');">
<option value="1" >Choice 1</option>
<option value="2" >Choice 2</option>
<option value="3" >Choice 3</option>
<option value="4" >Choice 4</option>
</select>

<input name="textbox" />
</form>
</body>

</html>
__________________
Vic

God Loves You and will never love you less.

http://www.vicsjavascripts.org.uk/

If my post has been useful please donate to http://www.operationsmile.org.uk/
vwphillips is offline   Reply With Quote
Old 12-04-2010, 02:41 PM   PM User | #3
Logic Ali
Regular Coder

 
Logic Ali's Avatar
 
Join Date: Sep 2010
Location: London
Posts: 961
Thanks: 0
Thanked 198 Times in 193 Posts
Logic Ali will become famous soon enoughLogic Ali will become famous soon enough
Within the scope of a form, elements can be addressed directly by name. So that example could use:

Code:
function TextBox( sel, nme ){
 nme.value = sel.value;
}

...........

<select name="select" size="1" onchange="TextBox( this, textbox );">
Logic Ali is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:13 AM.


Advertisement
Log in to turn off these ads.