When form is re-submitted via JavaScript on another page, one (and maybe more, I haven't looked) of the $_POST values is missing. Many others do exist.
A text box with the same name/id as the requested $_POST element exists on the submitted form (I've verified the name/id.) and that text box contains text, but PHP is throwing an "Undefined index:" error when I do a "$v = $_POST['xx']". I did a dump of the $_POST elements and it is not there.
If, however, I re-submit from the form itself (not from another open page), that $_POST value DOES exist.
As a note, there are over 100 fields on the re-submitted page. Don' t know if this would affect it, or not.
Has anyone heard of this behavior and, if so, how to correct?
Thanks,
Bruce
JavaScript that submits page. It is on the active window, function is called by a button click:
function CloseIt(){ if (!(window.opener.document.adiApproveOrder == undefined) && !(window.opener.document.adiApproveOrder.closed)) { var actn = document.getElementById("action").value; if (actn == "approved") { window.opener.document.adiApproveOrder['action'].value = "deliver"; } else if (actn == "submitted") { window.opener.document.adiApproveOrder['action'].value = "submitted"; } else { window.opener.document.adiApproveOrder['action'].value = ""; } window.opener.document.adiApproveOrder.submit(); } window.close();}
Is the "action" id non-unique within the page? If so, renaming it to "myaction" or something else unique would fix the issue.
springthorpeSoftware
ASKER
Thanks for replying! No, "$action" is a unique value. It's stored in a hidden text box. Both pages use it, however.
The control for it on the "main" page is being properly loaded by the JS on the "calling" page. That value is part of the $_POST array on the main page when it is re-submitted.
Bruce
Terry Woods - Yes. Button on "main" page re-submits it with a specific $action value, which triggers opening of "sub" page (a new page on top of the main). Sub page generates one or more pdf files and opens them in new windows for viewing. On sub page, user then clicks a button, which loads field "action" on the main form, re-submits main, then closes itself.
gr8Gonzo - Following is my "testing" code, at top of main page, just after include files are loaded and session is started:
// logs error if post value does not exist
echo "value: " . $_POST['ord_seller_units'] . '<br>';
// if posts are supposed to be there, dump them.
if (isset($_POST['action'])) {
foreach ($_POST as $f => $v) {
echo $f . ': ' . $v . '<br>';
}
}
// this is the control code on the main page
<input type="text" name="ord_seller_units" id="ord_seller_units" size="4"
style="text-align:center"
value="<?php echo $ord_seller_units;?>" onchange="ChangedSellerUnits()" />
Terry, unfortunately, I'm not allowed to show all of the code, just snippets. Can't give you a link due to security policies.
Went back through the code twice, including your suggestion of looking at the html. There were no PHP, JS, or html errors. Added echos and alerts of values before and after. Could not find reason for 4 of the fields not having $_POST values on reload. All 4 had fields visible on the main form with correct values when the dialog was opened.
Solved by having "main" page re-read data from database when dialog is closed. (The records are saved on the main page before the dialog is opened.) Have something that works, so this will have to remain a mystery.
Awarding you the points because you spent so much time on it.
Thanks, again.
Bruce