SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2005
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    value of Drop Down

    Hi,
    I have two dropdowns. In first dropdown i have two languages say english, persian. When i select english in 2nd dropdown iam able to show list of english movies. Problem is i need first dropdown selected value to use for second dropdown onchange. How can i use first dropdown value for second one?.

    this is select box code for second dropdown

    <select id="Moviename" name="Moviename" onChange="showCustomer(lan)">

    Here lan is language that selected in first dropdown. How can i get that lan value to here???.

    Please Help.

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Inside the showCustomer() function, use document.getElementById() to obtain the first select:

    Code:
    <html>
    <head><title></title>
    
    
    <script type="text/javascript">
    
    function myFunc(elmt)
    {
    	var firstVal = document.getElementById("s0").value;
    	alert(firstVal + " " + elmt.value);
    		
    }
    
    </script>
    </head>
    <body>
    
    <form name="f" method="post" action="">
    
    <select id="s0" name="s0">
    <option value="english">English</option>
    <option value="persian">Persion</option>
    </select>
    
    <select id="s1" name="s1" onchange="myFunc(this)">
    <option value="0">choose movie</option>
    <option value="movie1">movie 1</option>
    <option value="movie2">movie 2</option>
    </select>
    
    <input type="submit" value="Submit" />
    </form>
    </body>
    </html>

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2005
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <select id="Language" name="Language">
    <option value="">Select Language</option>
    <option value="">English</option>
    </select>

    <tr>
    <td>Moviename</td>
    <td><label>
    <script>
    var sel = document.getElementById("Language");
    var lan = sel.options[sel.selectedIndex].text;
    </script>
    <select id="Moviename" name="Moviename" onChange="showCustomer(this.value, lan)">
    </select> <span class="error">*</span></label></td>
    </tr>


    This is my code. With i am getting only first value of drop down even if i select second value.

    Can you please check


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
  •