value of Drop Down

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bootzwiz
    New Member
    • Jan 2007
    • 14

    #1

    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="showC ustomer(lan)">

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

    Please Help.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    If your code for 1st dropdown is
    [HTML]<select id="Language" name="Language" >[/HTML]
    then the following code
    Code:
    var sel = document.getElementById("Language");
    var lan = sel.options[sel.selectedIndex].text;
    will give you the value you require. Put that in a function and call that on change or just put this code in showCustomer.

    Comment

    • abctech
      New Member
      • Dec 2006
      • 157

      #3
      Originally posted by bootzwiz
      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="showC ustomer(lan)">

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

      Please Help.
      Go through this..

      Comment

      • bootzwiz
        New Member
        • Jan 2007
        • 14

        #4
        Originally posted by acoder
        If your code for 1st dropdown is
        [HTML]<select id="Language" name="Language" >[/HTML]
        then the following code
        Code:
        var sel = document.getElementById("Language");
        var lan = sel.options[sel.selectedIndex].text;
        will give you the value you require. Put that in a function and call that on change or just put this code in showCustomer.

        Hi,

        <tr>
        <td>Moviename </td>
        <td><label>
        <script>
        var sel = document.getEle mentById("sType ");
        var lan = sel.options[sel.selectedInd ex].text;
        </script>
        <select id="Moviename" name="Moviename " onChange="showC ustomer(this.va lue, lan)"> </label></td>
        </tr>


        Using this iam getting only first value of dropdown. Iam not getting selected value. Can you please check.

        Comment

        • chunk1978
          New Member
          • Jan 2007
          • 224

          #5
          this page was very helpful for me when i was trying to learn how to do the same thing a while back... read the whole page (it's not long) and pay close attention to the "More Options" section where it talks about dropdown menus.

          Comment

          • bootzwiz
            New Member
            • Jan 2007
            • 14

            #6
            Originally posted by chunk1978
            this page was very helpful for me when i was trying to learn how to do the same thing a while back... read the whole page (it's not long) and pay close attention to the "More Options" section where it talks about dropdown menus.

            http://www.mediacollege.com/internet.../add-text.html

            it doesnt help. thanks for link.

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              Originally posted by bootzwiz
              Hi,

              <tr>
              <td>Moviename </td>
              <td><label>
              <script>
              var sel = document.getEle mentById("sType ");
              var lan = sel.options[sel.selectedInd ex].text;
              </script>
              <select id="Moviename" name="Moviename " onChange="showC ustomer(this.va lue, lan)"> </label></td>
              </tr>


              Using this iam getting only first value of dropdown. Iam not getting selected value. Can you please check.
              You will only get the first value because you are only using the code once on page load. You need to use the code when the second list changes, so put the two lines into your showCustomer function. You can get rid of the second argument, lan, from the function call.

              Comment

              • bootzwiz
                New Member
                • Jan 2007
                • 14

                #8
                Iam not getting it Can you please write a code of it.

                Comment

                • AricC
                  Recognized Expert Top Contributor
                  • Oct 2006
                  • 1885

                  #9
                  Originally posted by bootzwiz
                  Iam not getting it Can you please write a code of it.
                  Bootzwiz,
                  Why did you report this to me and tell me to write the code? I think you are misunderstandin g the purpose of this forum. We are here to help. You need to make a valid effort at producing some code. We are not here to write your functions for you. You need to at least try, post the code you have tried that is not working and state specifically the problem.


                  Thanks,
                  Aric

                  Comment

                  • bootzwiz
                    New Member
                    • Jan 2007
                    • 14

                    #10
                    sorry....i think i made a mistake instead of click on reply i clicked on report and posted...I made an effort i asked here after i tried everything.

                    Please ignore it.

                    Comment

                    • acoder
                      Recognized Expert MVP
                      • Nov 2006
                      • 16032

                      #11
                      Originally posted by bootzwiz
                      Iam not getting it Can you please write a code of it.
                      In your showCustomer function include the two lines that you have beginning with
                      Code:
                      var sel = ...
                      Also, get rid of the second argument in showCustomer both when defining the function and calling it:
                      [HTML]<select id="Moviename" name="Moviename " onChange="showC ustomer(this.va lue)"> [/HTML]
                      If you still can't figure it out, post your showCustomer code.

                      Comment

                      Working...