Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Copy options

  1. #1
    New Coder
    Join Date
    Sep 2002
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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 ---------------

  • #2
    Regular Coder
    Join Date
    Mar 2003
    Posts
    176
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copy options

    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).

  • #3
    New Coder
    Join Date
    Mar 2003
    Location
    Somewhere far beyond
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •