简体   繁体   中英

Passing same id as parameter in invoking function and the defined function

I have a select menu . On selecting the values it triggers getvalyear() function passing selected option as parameter. I need to call the getvalue() function inside display() function with same parameter described earlier. I also have to pass the argument to display() function.

Any helps are recommended.

Code snip of my description is described below.

   <select name="year" id="year"  style="width: 200px" onchange="getvalue(this)">
              <option>--Select Year--</option>
              <option value="2014">2014</option>
              <option value="2015">2015</option>
              <option value="2016">2016</option>
              <option value="2017">2017</option>   
              <option value="2018">2018</option>
    </select>



<script type="text/javascript">

 function getvalue(ctrl1){

      var sel = ctrl1.selectedIndex; 
      var selVal1 = ctrl1.options[sel].value; 

    }

function display(clicked_id)
{
    getvalyear(id);
}

</script>

If I understood the problem, you can try this code to display select boxes manually:

function display(clicked_id) {
    getvalue($('#' + clicked_id)[0]);
}

// select year
display('year');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM