javascript - How to tell which selectbox has a changed value using PHP? -


i have 2 selectboxes on web page. 1 displays monthly report while displays archived monthly report. set value "current" or "archived" based on selectbox used. have done point.

<script>     $(document).ready(function(){         $('#smonth').change(function(){             <?php $viewtype = 'current'; ?>         }).change();         $('#sreporturl').change(function(){             <?php $viewtype = 'archived'; ?>         }).change();     }); </script> 

when load page, value want not appear on web page. there missing value appear?

use ajax:

<div id="report"> </div> 

and mod script this:

 $(document).ready(function(){         $('#smonth').change(function(){             $('#report').load('report.php?viewtype=current');         });         $('#sreporturl').change(function(){             $('#report').load('report.php?viewtype=archived');         });     }); 

and report.php:

$viewtype = filter_input(input_get, 'viewtype');  if($viewtype == 'archived'){ echo $archivedreport; }else{ echo $currentreport; } 

Comments