Link to home
Start Free TrialLog in
Avatar of kkbenj
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?
<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."'; />";
?>

Open in new window

Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

change:

this.account-form.rcptdate.value


to this.value

Cd&
Sorry I miss read it

change it to  forms.account-form.rcptdate.value

Cd&
Avatar of kkbenj
kkbenj

ASKER

Changing this.account-form.rcptdate.value to forms.account-form.rcptdate.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.
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!
ASKER CERTIFIED SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kkbenj

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&