gardan06 Posted May 19, 2008 Share Posted May 19, 2008 function updatePOHead(url) { if (url==undefined) url=''; var arr = new Array(); var optVendorKey = document.getElementById("optVendorKey").value; var optShipToKey = document.getElementById("optShipToKey").value; var txtPONumber = document.getElementById("txtPONumber").value; var optPOStatus = document.getElementById("optPOStatus").value; var optTermsKey = document.getElementById("optTermsKey").value; //var txtDiscount = document.getElementById("txtDiscount").value; var txtOrderDate = document.getElementById("txtOrderDate").value; var txtDeliveryDate = document.getElementById("txtDeliveryDate").value; var optPOType = document.getElementById("optPOType").value; var txtCancelDate = document.getElementById("txtCancelDate").value; //var radTermsKey; var txtDiscount = 0; var radTermsKey = ''; var controls = document.frmPO.length; var cnt = 0; var element; for (i = 0; i < controls; i++) { element = document.frmPO[i]; if (element.type == "radio") { if (element.checked == true) { radTermsKey = element.value; cnt++; } } } arr.push(optVendorKey); arr.push(optShipToKey); arr.push(optPOStatus); arr.push(optTermsKey); arr.push(txtDiscount); arr.push(radTermsKey); arr.push(txtOrderDate); arr.push(txtDeliveryDate); arr.push(optPOType); arr.push(txtCancelDate); //alert(arr.toString()); if(confirm("Save all changes?")) { alert(url); agent.call("", "updatepodraft", "callback_updatePOHead", txtPONumber, url, arr.toString()); } else { window.location=url; } } function callback_updatePOHead(response) { var message = document.getElementById("message"); alert(response[0]); alert(response[1]); return false; if (response[1]=='') { if(response[0]==1) response[0] = 'RECORD SAVED'; else response[0] = 'RECORD NOT SAVED, ERROR RUNNING COMMAND'; message.innerHTML = response[0]; } else { alert('Record Saved'); window.location=response[1]; } } function updatepodraft($po, $url, $arr) { global $db; $h = array(); $h = split(',',$arr); $sql = sprintf("update purchase_hdr set actual_vendor_code = '%s', ship_location_code = %s, po_status = '%s', terms_code = '%s', discount = %01.03f, discount_type = '%s', po_date = '%s', recdate = '%s', item_type_code = '%s', canceledbydate = '%s' where po_no = '%s'", $h[0], $h[1], $h[2], $h[3], $h[4], $h[5], $h[6], $h[7], $h[8], $h[9], $po); /*$rs = $db->db_query($sql); if(!$rs) $bjarr[0] = false; else $bjarr[0] = true;*/ $bjarr[0] = $sql; $bjarr[1] = $url; //$db->db_free_result($rs); return $bjarr; } What im trying to do is save the url as it was called from the javascript function to the PHP function and then back to the callback javascript function for the wind.location command. But the weird part is that somewhere between the javascript to php agent function, the url gets cut short (i.e. index.php?mode=po_entry&sub=header&po=xxxx becomes index.php?mode=po_entry). I have tried to error check if there's another way the url got cut short, but as i error checked every javascript code leading to the php code, i concluded that the problem would have occured on the translation to the php code. in addition, the url always get cut short to index.php?mode=po_entry, which made me think that the ampersand (&) probably have something to do with it, but it didnt. So pphp gurus, i ask for your help. Please tell me what went wrong in my code? Thanks. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted May 19, 2008 Share Posted May 19, 2008 the ampersand is probably the problem. you may need to url_encode the url via javascript. don't know how it's done, but i bet google does. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.