开发者

Get a value from a form item in PHP

Basically Iv got PayPal items set up and I have for instance a text input feild called ItemQuantity1

When I press the corosponding add to cart button, I want it t开发者_Python百科o use the value of ItemQuantity1 to fill the variable for quantity which PayPal uses.

so if I have: |15_____| |Add to cart|

when I push add to cart I want it to say that I added 15 of this item.

I tried doing

... name=quantity value=$temQuantity1

but this didnt work

Thanks


if this is a request variable (submitted via form, or otherwise put into the request), you can access this value with $_REQUEST['itemQuantity1'].


So you would start by submitting the value of the text box (itemQuantity1) to your cart handler. Once you have the data you can do the following to populate the hidden field.

<?php 
$itemQuantity = $_REQUEST['itemQuantity1'];
$itemQuantity = htmlentities($itemQuantity, ENT_QUOTES);
?>
<input type="hidden" name="quantity" value="<?php echo $itemQuantity;?>"/>

If you need to do this on the same page you can do it with JavaScript but would probably be better off just renaming the itemQuantity1 text box to quantity.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜