SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot ginieg's Avatar
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Passing Values (text box --> drop down)

    Hi guys!

    I am not Javascript savvy at all and I would like some help from you...
    How can I pass the value of a tex box in a drop down menu by clicking a button?

    Thanks!
    Ginie G.

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, your quarterback is the select box. But who's your receiver?

    </smartaleck>

    Seriously, what do you want to pass this to? A text box? A javascript variable? Another page?
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  3. #3
    SitePoint Zealot ginieg's Avatar
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, the receiver is ... a drop down menu.

    I guess it would be easier to understand if you can actually see what I want to do.
    Go to www.travelflip.com/test.htm

    Basically, I want my users to build a list of dates (in the drop down menu).

    Can you help me out?

    Thanks!
    Ginie G.

  4. #4
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check out this sample page, and see if you can apply it to yours...
    Code:
    <html>
    <head>
    <title>untitled</title>
    <script type="text/javascript" language="javascript">
    function addOption(f, sID, val, label) {
    	var o = document.createElement("OPTION");
    	var t = document.createTextNode(label);
    	o.appendChild(t);
    	o.value = val;
    	f.elements[sID].appendChild(o);
    	}
    </script>
    </head>
    <body>
    <form>
    <input type="text" name="date">
    <input type="button" value=">>>" onClick="addOption(this.form,'vac_black',this.form.date.value, this.form.date.value)">
    <select size="2" name="vac_black"></select>
    </form>
    </body>
    </html>
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  5. #5
    SitePoint Zealot ginieg's Avatar
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot!
    It worked!
    Ginie G.

  6. #6
    SitePoint Zealot ginieg's Avatar
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Remove Button

    Hello, me again!

    How could I add a "Remove Button" which would a selected option in the drop down menu?
    Ginie G.

  7. #7
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Let's see if you can figure this one out

    The method I recommend for removing nodes is

    object.removeChild(childNode);

    example:
    var s = document.forms[0].elements['vac_black'];
    s.removeChild(s.options[2]);

    Hint: In a SELECT, the child's index in it's parent's options collection is identical to it's selectedIndex
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  8. #8
    SitePoint Zealot ginieg's Avatar
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well...
    Right now, Javascript is like Ancient Chinese to me.
    Thank you for showing me the code!
    Ginie G.

  9. #9
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    function removeOption(e) {
    e.removeChild(e.options[e.selectedIndex]);
    }

    <input type="button" value="<<<" onClick="removeOption(this.form.vac_black);">
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev





Bookmarks

Posting Permissions

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