Page 1 of 1

variables to html form?

Posted: Fri Oct 18, 2002 4:13 am
by BarryS
I need help on how to get the php variables from my shopping cart. I need to get the variables cartid and value into the html form before submitting.

The html is:
<input type="hidden" name="cartId" value="Merchant Test">
<input type="hidden" name="amount" value="10.00">
<input type="submit" value="Secure Online Payment">

Is there another way in html and how do I send the same info without a "submit" keystroke.

Any help would be appreciated.

Posted: Fri Oct 18, 2002 4:20 am
by adcworks
well presumably you would do something like

<input type="hidden" name="cartId" value="<?php print($cartid); ?>">
<input type="hidden" name="amount" value="<?php print($value); ?>">
<input type="submit" value="Secure Online Payment">

you would need the variables available from somewhere .. maybe your session, depends how your cart works.

Posted: Fri Oct 18, 2002 5:00 am
by Zeceer
Or you can use the echo function:
<input type="hidden" name="cartId" value="<?=$yourvariable?>">

Posted: Fri Oct 18, 2002 8:49 am
by volka
note: for <?= $var ?> syntax you have to enable short_open_tag

a form element has a submit()-method that you can call i.e. from javascript.