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
  1. #1
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    passing info from a pull down menu

    I am a newbie with a newbie question. I have a pull down menu with names in it. I have a button beside the menu called "select". I also have empty text fields. I want to be able to select a users name in the menu and press the "select" button and have it pass the name into one of the blank text fields.

    Basically I have been doing javascript for two days now, and I know how to make a pulldown menu and I know how to make a button. I just don't understand how I can define say optionX in the menu to something that I could then use an event (i think) along with onClick to say set optionX as a stringX, and then I don't know how to say put stringX into this text field.

    I tried looking for example of this type of code online and failed. Also, keep in mind i'm not really knowledgeable at all when it comes to setting up the script stuff that usually goes in the <head> tags. Any help would be greatly, greatly appreciated.

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello and welcome here!

    Firstly, I think your description of your problem is good, then only other thing that might help is the HTML of your form (without the Javascript obviously as that's what we'll help you create).

    If we can see the HTML, then we know the structure and can get a confirmation of your problem description. From there, I think we will introduce the DOM to you, as it will help you to achieve your goal.

    Sadiq.

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <script type="text/javascript">
    <!--
    
    
    
    function getVal(){
    
    var doc = document['oFrm'];
    doc['oTxt'].value = doc['oSel'].options[doc['oSel'].selectedIndex].text;
    
    }
    
    
    //-->
    </script>
    
    
    <form name="oFrm">
    <select name="oSel">
    <option value="oName1">Matthew</option>
    <option value="oName2">Mark</option>
    <option value="oName3">Luke</option>
    <option value="oName4">John</option>
    </select>&nbsp;<input name="oTxt" type="text" size="15" />&nbsp;<input name="oBtn" type="button" value="select" onclick="getVal();" />
    </form>


    -james
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "


  •  

    Posting Permissions

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