...

View Full Version : Copy options



midez
04-11-2003, 09:58 AM
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 ---------------

HairyTeeth
04-11-2003, 01:07 PM
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). :)

Weirdan
04-11-2003, 01:49 PM
<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");
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum