www.webdeveloper.com
Results 1 to 2 of 2

Thread: Multiple Dropdowns on one page

Hybrid View

  1. #1
    Join Date
    Sep 2013
    Posts
    1

    Multiple Dropdowns on one page

    I have six dropdowns on one page which are dynamically filled using javascript android.

    On button click, i want to check which among 6 dropdown user had click or selected value?

    Can we have this in javascript if yes how? Please help me its urgent.


    Regards,
    Phonegap Android Developer

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,653
    i know nothing about javascript on android but a webpage with required functionality might look as below

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>selects</title>
    <style>
    body{color:#000;background-color:#fff;font-family:'Bookman Old Style',Georgia,Verdana;font-size:14px;text-align:center;padding-top:100px;}
    #res{text-align:center;padding:50px;}
    </style>
    <script>
    var last_active_sel_id='',last_selected_value='';
    function activateSelects(){
    var sels=document.getElementsByTagName('select');
    for(var i=0;i<sels.length;i++){
    sels[i].onclick=sels[i].onchange=function(){
    last_active_sel_id=this.id;
    last_selected_value=this.options[this.selectedIndex].value;
    document.getElementById('l_a_s_id').innerHTML='The last clicked select element id is <b>'+last_active_sel_id+'</b>';
    document.getElementById('l_s_val').innerHTML='The last selected value is <b>'+last_selected_value+'</b>';
    }
    }
    }
    window.onload=activateSelects;
    </script>
    </head>
    <body>
    <form id="mf">
    <select name="sel_1" id="sel_1">
    <option value="1">option 1</option>
    <option value="2">option 1</option>
    <option value="3">option 1</option>
    <option value="4">option 1</option>
    <option value="5">option 1</option>
    </select>
    <select name="sel_2" id="sel_2">
    <option value="1">option 1</option>
    <option value="2">option 1</option>
    <option value="3">option 1</option>
    <option value="4">option 1</option>
    <option value="5">option 1</option>
    </select>
    <select name="sel_3" id="sel_3">
    <option value="1">option 1</option>
    <option value="2">option 1</option>
    <option value="3">option 1</option>
    <option value="4">option 1</option>
    <option value="5">option 1</option>
    </select>
    <select name="sel_4" id="sel_4">
    <option value="1">option 1</option>
    <option value="2">option 1</option>
    <option value="3">option 1</option>
    <option value="4">option 1</option>
    <option value="5">option 1</option>
    </select>
    <select name="sel_5" id="sel_5">
    <option value="1">option 1</option>
    <option value="2">option 1</option>
    <option value="3">option 1</option>
    <option value="4">option 1</option>
    <option value="5">option 1</option>
    </select>
    <select name="sel_6" id="sel_6">
    <option value="1">option 1</option>
    <option value="2">option 1</option>
    <option value="3">option 1</option>
    <option value="4">option 1</option>
    <option value="5">option 1</option>
    </select>
    </form>
    <div id="res"><div id="l_a_s_id"></div><div id="l_s_val"></div></div>
    </body>
    </html>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles