javascript - Use ajax to pass the value of selected dropdown as an argument to a function in another dropdown -


i need advice ajax function building , haven't been able figure out far. have select order_by dropdown uses ajax function called searchfilter change this.value variable called $orderr_by:

<select name="order_by"          onchange="searchfilter('0',                                '<?php echo $maxrows;?>',                                this.value);"> 

i have select condition dropdown calls same searchfilter function , should new $orderr_by argument, when onchange event triggered order_by dropdown.

below have got work 3 static arguments need make work when $orderr_by argument changed:

<select name="condition" id="condition"          onchange="searchfilter('<?php echo $pagenum;?>',                                '<?php echo $maxrows;?>',                                '<?php echo $orderr_by; ?>');"> 

my axaj looks this:

function searchfilter(pagenumbr,maxrows,order_by) {      var filter  = jquery.noconflict();      filter.post(         mysurl+'ajaxphp/searchfilters.php?page_no='+pagenumbr+'&max_rows='+maxrows+'&order_by='+order_by,          filter('#filterfrm').serialize(),           function(html){               arrhtml = html.split('<####>');             filter('#resultcontainer').html(arrhtml[0]);             }     );      } // function searchfilter() 

select value of [name=order_by] element.

in pure js follows:

var element = document.getelementbyid("order_by"); var order_by = element.options[element.selectedindex].value; 

jquery has cleaner ways of doing this.

you not need order_by in function declaration. if reason need pass order_by other code, have make sure order_by not defined:

if (order_by === undefined) {    ... } 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -