php - Problems passing parmaters in Javascript -


i trying pass several variables php page java script. first parameter being passed.

the php page calls script this:

<? $sdate = 0; $edate = 2; ?> <script type="text/javascript">             window.onload = function() {                  datagrid = new databasegrid('<? echo $sdate; ?>', '<? echo $edate; ?>');             };  </script><br> 

the java script being called is:

function databasegrid(sdate, edate)  {      this.editablegrid = new editablegrid("demo", {         enablesort: true,         tableloaded: function() { datagrid.initializegrid(this); },         modelchanged: function(rowindex, columnindex, oldvalue, newvalue, row) {             updatecellvalue(this, rowindex, columnindex, oldvalue, newvalue, row);         }     });     this.fetchgrid(sdate);     this.fetchgrid(edate);   }  databasegrid.prototype.fetchgrid = function(sdate, edate)  {     // call php script data     alert("loaddata_dailyotp.php?o=" + sdate + "&e=" + edate + "");     this.editablegrid.loadxml("loaddata_dailyotp.php?o=" + sdate + "&e=" + edate + ""); };  databasegrid.prototype.initializegrid = function(grid) {     grid.rendergrid("tablecontent", "testgrid"); };   

i added alert window show being requested. expecting this:

loaddata_dailyotp.php?o=0&e=2

however getting is:

loaddata_dailyotp.php?o=0&e=undefined

why second parameter not going through?

you not passing "edate" parameter fetchgrid() call. that's why it's displayed "undefined". reason you're calling fetchgrid() 2 times instead.


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -