sepoto Posted March 15, 2013 Share Posted March 15, 2013 Although I can console.log lastSel it is coming up as a blank when the PHP is called in the header. So when the header is passed it is id: "" even though clearly there is a value in lastSel and I am type casting to string. I am wondering what could be the source of the issue. lastSel is defined outside of any function braces as just "lastSel = """ without using the var keyword. Why would it be blank as String(lastSel) even though I can console.log a value? <script>$(function(){var date = new Date();var d = date.getDate();var m = date.getMonth();var y = date.getFullYear(); $('#calendar1').fullCalendar({ // put your options and callbacks hereheader:{left: 'prev,next today',center: 'title',right: 'month,basicWeek,basicDay'},editable: true,droppable: true,selectable: true,events: {url: 'php.scripts/events.get.php',type: 'POST',data: {id: String(lastSel),custom_param2: 'somethingelse'},error: function() {alert('there was an error while fetching events!');},color: 'yellow', // a non-ajax optiontextColor: 'black' // a non-ajax option},eventClick: function (calEvent, jsEvent, view) { $( "#eventdialog2" ).dialog({resizable: false,height:500,width:500,modal: true,buttons: {"Update": function() {$( this ).dialog( "close" );},Cancel: function() {$( this ).dialog( "close" );}}}); },eventDrop: function (event, dayDelta, minuteDelta, allDay, revertFunc) { },select: function(startDate, endDate, allDay, jsEvent, view) { $( "#eventdialog1" ).dialog({resizable: false,height:500,width: 500,modal: true,buttons: {"Add": function() {if(jQuery("#event_title1").val() == ""){alert("All active text fields are required input!");return false;}$( this ).dialog( "close" );},Cancel: function() {$( this ).dialog( "close" );}}}); } }); $('#calendar2').fullCalendar({ // put your options and callbacks here });});</script> <script>lastSel = "";$(function(){ $("#list").jqGrid({ url:'php.scripts/get.customers.php', datatype: 'xml', mtype: 'POST',colNames:['idcustomers','firstname', 'lastname','address1','address2','city','state','zip','phone','email','cell'], colModel :[ {name:'idcustomers', index:'idcustomers', width:55}, {name:'firstname', index:'firstname', width:90, editable: true}, {name:'lastname', index:'lastname', width:90, editable: true}, {name:'address1', index:'address1', width:90, editable: true}, {name:'address2', index:'address2', width:90, editable: true}, {name:'city', index:'city', width:90, editable: true}, {name:'state', index:'state', width:90, editable: true}, {name:'zip', index:'zip', width:90, editable: true}, {name:'phone', index:'phone', width:90, editable: true}, {name:'email', index:'email', width:90, editable: true}, {name:'cell', index:'cell', width:90, editable: true} ], pager: '#pager', rowNum:20, rowList:[20,100,300], sortname: 'idcustomers', sortorder: 'asc', viewrecords: true, gridview: true, caption: 'Customers',width: 1400,height: 290,editurl: 'php.scripts/update.row.php',ajaxGridOptions: {type:"POST"},onSelectRow: function(id){ if(id && id!==lastSel){ jQuery('#gridid').restoreRow(lastSel); lastSel=id;jQuery("#list").data('selid',lastSel);console.log(lastSel);console.log(jQuery("#list").data('selid'));} //jQuery('#list').editRow(id, true); jQuery('#list').data('selid', jQuery("#list").getCell(lastSel,0));jQuery('#list').data('firstname', jQuery("#list").getCell(lastSel,1));jQuery('#list').data('lastname', jQuery("#list").getCell(lastSel,2));jQuery('#list').data('address1', jQuery("#list").getCell(lastSel,3));jQuery('#list').data('address2', jQuery("#list").getCell(lastSel,4));jQuery('#list').data('city', jQuery("#list").getCell(lastSel,5));jQuery('#list').data('state', jQuery("#list").getCell(lastSel,6));jQuery('#list').data('zip', jQuery("#list").getCell(lastSel,7));jQuery('#list').data('phone', jQuery("#list").getCell(lastSel,8));jQuery('#list').data('email', jQuery("#list").getCell(lastSel,9));jQuery('#list').data('cell', jQuery("#list").getCell(lastSel,10)); } }).jqGrid('navGrid','#pager',{ edit: false, add: true }, {}, {}, {}, {}, {}).jqGrid('inlineNav',"#pager",{}); }); </script> Link to comment Share on other sites More sharing options...
justsomeguy Posted March 15, 2013 Share Posted March 15, 2013 It's empty when that Javascript runs. If it wasn't empty, it would show undefined instead of an empty string. It's finding the global variable, which is empty. You would need to run the fullCalendar code again after setting that variable to something else. Link to comment Share on other sites More sharing options...
sepoto Posted March 16, 2013 Author Share Posted March 16, 2013 Thank you for that reply. I have currently found a way to use PHP to solve the problem but I will learn from this as a learning experience. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now