Jump to content

html button to pass variable content


lassoloc

Recommended Posts

Hello World,

 

I need some tips on how to make a button that does something like the code below.

 

.......echo '<tr><td align="left"><a href="add_cart.php?pid=' . $row1['item_id'] . '">Add to Cart</a></td>........

 

I've been messing with html form and button type with no success. This code does the job but I prefer a button.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/220712-html-button-to-pass-variable-content/
Share on other sites

so why not use the same code and use an image instead of text?

 

Anyways...

 

in order to mimic that with a form without changing anything in add_cart.php, the code would look something like this:

echo <<<FORMENT
<form name="someform" action="add_cart.php" method="get">
<input type="hidden" name="pid" value="{$row1['item_id']}" />
<input type="submit" value="Add to Cart" />
</form>
FORMENT;

<a href="add_cart.php?pid=' . $row1['item_id'] . '"><input type="button" value="add to cart" name="Addtocart" /></a>

 

Just make the button or image or whatever in between your anchor tags.

 

I've tried this. For some reason this doesn't work for me. I get the  button but clicking does nothing. Image doesn't work but text does.  :confused:

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.