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 04-11-2003, 09:58 AM   PM User | #1
midez
New Coder

 
Join Date: Sep 2002
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
midez is an unknown quantity at this point
Question Copy options

Please someone help. I want this to work like this: when you choose i.e. "demo 1" in the select box it takes "demo 1" and puts it in the text box "country". Now it puts the "value" in the box. How do i do that?

Thanks, Mike //

--------- The code ------------------

<form>
<SELECT NAME="recipient" SIZE="1" onChange="this.form.country.value=this.value;">
<OPTION value="demo1@mm.com" selected="true">demo 1</OPTION>
<OPTION value="demo2@mm.com">demo 2</OPTION>
<OPTION value="demo3@mm.com">demo 3</OPTION>
<OPTION value="demo4@mm.com">demo 4</OPTION>
</SELECT>
<input type="text" name="country" size="15" value="" onChange="this.value=this.form.recipient.value;">
</form>

---------- End of code ---------------
midez is offline   Reply With Quote
Old 04-11-2003, 01:07 PM   PM User | #2
HairyTeeth
Regular Coder

 
Join Date: Mar 2003
Posts: 176
Thanks: 0
Thanked 0 Times in 0 Posts
HairyTeeth is an unknown quantity at this point
Re: Copy options

Quote:
Originally posted by midez

<form>
<SELECT NAME="recipient" SIZE="1" onChange="this.form.country.value=this.form.recipient[this.form.recipient.selectedIndex].text;">

<OPTION value="demo1@mm.com" selected="true">demo 1</OPTION>
<OPTION value="demo2@mm.com">demo 2</OPTION>
<OPTION value="demo3@mm.com">demo 3</OPTION>
<OPTION value="demo4@mm.com">demo 4</OPTION>
</SELECT>
<input type="text" name="country" size="15" value="" onChange="this.value=this.form.recipient.value;">
</form>

I'm not quite sure what your trying to achieve with this form...but it does what you want (i think).
HairyTeeth is offline   Reply With Quote
Old 04-11-2003, 01:49 PM   PM User | #3
Weirdan
New Coder

 
Join Date: Mar 2003
Location: Somewhere far beyond
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
Weirdan is an unknown quantity at this point
Code:
<form>
  <SELECT NAME="recipient" SIZE="1" onchange="fill(this)">
    <OPTION value="demo1@mm.com" selected='true'>demo 1</OPTION>
    <OPTION value="demo2@mm.com">demo 2</OPTION>
    <OPTION value="demo3@mm.com">demo 3</OPTION>
    <OPTION value="demo4@mm.com">demo 4</OPTION>
  </SELECT>
  <input type="text" name="country" size="15" value="" onChange="fill(this.form.recipient)">

	function fill(combo)
	{
  		combo.form.country.value = combo.options[combo.selectedIndex].getAttribute("value");
	}
__________________
WBR, Weirdan.
Weirdan 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 11:12 AM.


Advertisement
Log in to turn off these ads.