kkbenj
asked on
PHP or Javascript
I have 2 buttons on a page. Each calls the same resulting page, but I want to pass a hidden field filled with a different variable for each button.
My PHP code is very simple. Shown is one of the 2 buttons. But in checking the posted values on the subsequent page, it is blank.
What am I doing wrong?
My PHP code is very simple. Shown is one of the 2 buttons. But in checking the posted values on the subsequent page, it is blank.
What am I doing wrong?
<form id='account-form' action='abc.php' method='POST'>
<INPUT type='hidden' name='rcptdate'>
<?php
$DonateDt="20111107";
echo "<input class='pill-button' type='submit' value='Receipt' onClick='this.account-form.rcptdate.value=".$DonateDt."'; />";
?>
Sorry I miss read it
change it to forms.account-form.rcptdat e.value
Cd&
change it to forms.account-form.rcptdat
Cd&
ASKER
Changing this.account-form.rcptdate .value to forms.account-form.rcptdat e.value did not work.
Just to be clear, I need to be able to set the value of the hidden field on click. The php code takes care of filling the variable $DonateDt, then upon click it needs to assign it.
Just to be clear, I need to be able to set the value of the hidden field on click. The php code takes care of filling the variable $DonateDt, then upon click it needs to assign it.
You can use var_dump($_POST) to see the contents of the post array.
If you have two submit buttons, why no just detect which button was submitted by testing the value of the named submit button? Easy!
If you have two submit buttons, why no just detect which button was submitted by testing the value of the named submit button? Easy!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cobol - perfect and easy solution. Thanks for the speedy responses.
It would have been better if I had been paying better attention and got it right the first time. Need more coffee I think. :^)
Cd&
Cd&
this.account-form.rcptdate
to this.value
Cd&