javascript - how to combine, .change(function() for two different type of input and send the values to same function parameter -


i have checkbox sending value function called sendtobox() upon checked. function makes ajax call fetch data database.

now want have range slider of html send value function.

how do please?

<script>        $(".slider").change(function() {        var value = $(this).val();        sendtobox(value);       });      $("input[type=checkbox]").change(function() {        var selectedval = $(this).val();      if($(this).is(":checked")) {         var selectedtext = $(this).next().text();         sendtobox(selectedval);      }       else {         $("th."+selectedval).remove();//controls removing boxa      }     });    </script> 

how alter above sends sendtobox(value1,value2);

by passing together, i'm trying achieve this:

the below function must accept 2 variables passed getsubjects.php. in php i'm retrieving value this:$r= $_get['r']; display in textbox.

function sendtobox(param,param2)             {               xmlhttp.onreadystatechange = function() {               if (xmlhttp.readystate == 4 && xmlhttp.status == 200) {               if (this.responsetext !== null) {                 var ajaxelm = document.getelementbyid('boxa');                 ajaxelm.innerhtml = this.responsetext + ajaxelm.innerhtml; // append in front                }               }             }                   xmlhttp.open("get","getsubjects.php?q="+param+"r="+param2,true);                  xmlhttp.send();              } 

edited

now know can pass via string url this:xmlhttp.open("get","getsubjects.php?q="+param+"&r="+param2,true);

but script not passing value correctly replaced param2 value digit 10, works.

in below code, while making ajax call, send slider value while calling input checkbox change , vice-a-versa. please check if helped solution.

<script>        $(".slider").change(function() {        var value = $('.slider').slider("option", "value");        sendtobox(value, $("input[type=checkbox]").val());       });      $("input[type=checkbox]").change(function() {        var selectedval = $(this).val();      if($(this).is(":checked")) {         var selectedtext = $(this).next().text();         sendtobox(selectedval, $('.slider').slider("option", "value"));      }       else {         $("th."+selectedval).remove();//controls removing boxa      }     }); </script> 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -