Results 1 to 2 of 2

Thread: javascript + select tags

  1. #1
    Join Date
    Jan 2011
    Posts
    10

    javascript + select tags

    hello everybody!!
    if you have many select tags how i can find the selections form every select tag??please in javascript code!!

    i wrote this but it's wrong because this code gives me the values from the first select tag

    function getoptionvalues() {
    var t="select30";
    for(var i=0;i<document.getElementById(t).length;i++){
    var x=document.getElementById(t)[i].value;
    alert(x); } }

    for example

    <select id="select30">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
    </select>

    <select id="select30">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
    </select>

    <select id="select30">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
    </select>

    <select id="select30">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
    </select>

  2. #2
    Join Date
    Jan 2011
    Posts
    10
    these days i read and learn more about my problem!so forget my previous post because is wrong
    the code is here:
    PHP Code:
    <div align="right" id="parent" name="parent">
    <
    select name="select30" id="select30" value=""/>here inside i have options values and work dynamically with query to my DB</select>
    <
    input type="button" id="moreFields" value="+" onclick=""/> //add select tags
    <input type="button" value="-" onclick="" /> //remove select tags
    <div name="child" id="writeclone"></div//here cloned the  child from parent DIV 
    </div>
    <
    input type="button" name="enter" id="" value="ENTER" onclick="getoptionvalues();"/> 
    My problem is how i can get the names or id's from child DIV when + button fired.When this button fired create child DIVs in Child DIV!!Can anybody HELP ME to correct my JAVASCRIPT code

    <script> function getoptionvalues() {
    var parent=document.getElementById('parent');
    for (var count=0;count<parent.childNodes.length;count++) {
    if(parent.childNodes[count].tagName =='DIV') {
    alert ('parent.childNodes[count]');
    }

    }

    } </script>
    Last edited by tasox; 06 May 2011 at 08:24 AM.

Similar Threads

  1. HOWTO Replace MAILTO HREF Tags with Javascript to prevent Spam
    By cberic3 in forum Web Design, HTML Reference and CSS
    Replies: 0
    Last Post: 29 Aug 2005, 12:31 PM
  2. maintaining a SELECT value in the SELECT tag??
    By numbenator in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 16 Aug 2005, 03:44 AM

Posting Permissions

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