Doing a FORM POST without a button or image?

Man of Honour
Joined
11 Mar 2003
Posts
10,706
Location
Greenock, Scotland
Is it possible to do an HTML FORM POST from a peice of text rather than a button or image?

I'm trying to add a Paypal shopping cart based purchasing system to my site (Coppermine based image gallery) and I've cracked everything bar the "View Basket" button. I want to add it into the menu at the top of the gallery so that it's visible at all times but I'm struggling to integrate it intot he coppermine theme. The buttons at present are test href links to other bits of PHP with the graphics applied as a background image to the table cell via a CSS style.

Basically I want it to look like this:

menu_good.jpg


but if I try and put an image in the View Basket cell for the POST (no CSS style on the cell) I get this:

menu_bad.jpg


As you can see the image knocks the menu out of line with the background and the spacer images.

So. What are my options for getting round this? The misaligned image works perfectly but looks naff and I'm not sure what I need to do to realign things.

Any help would be appreciated. Let me know if you want me to post some sample HTML etc.
 
Code:
<form method="post" action="foo.php" id="theform">
</form>

<a href="#" onclick="document.getElementById('theform').submit()">submit!</a>

This is a pretty clunky thing to do, though.
 
robmiller said:
This is a pretty clunky thing to do, though.

That looks OK but gives an error on execution - "Object does not support this property or method". The supplied line number points to the submit() line.

I take it the code below looks OK.

Code:
<!-- Store --> 
<td class="top_menu_bttn">
<a href="static_text.php?page_type=4" onMouseOver="MM_showHideLayers('Menu1','','hide')">Buy Prints</a>
</td>
<td><img name="menu_spacer" src="themes/rpstewart/images/menu_spacer.gif" width="2" height="35" border="0" id="menu_spcer" alt="" /><br /></td>

<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" id="basket_form">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="display" value="1">
</form>

<!-- Basket -->         
<td class="top_menu_bttn">
<a href="#" onclick="document.getElementByID('basket_form').submit()">View Basket</a>
</td>

<td><img name="menu_spacer" src="themes/rpstewart/images/menu_spacer.gif" width="2" height="35" border="0" id="menu_spcer" alt="" /><br /></td>

<!-- About -->          
<td class="top_menu_bttn">
<a href="static_text.php?page_type=1" onMouseOver="MM_showHideLayers('Menu1','','hide')">About</a>
</td>
 
Last edited:
If it's just a "show me my cart" post can't you just use a get? Just a link to viewcart.php or whatever? Do you really need to do a post?

If you could just use a link you wouldn't need to assume you users are going to have javascript... Sometimes I turn off if I'm using stumbleupon (which takes you to lots of sites with semi-unblockable popups)...
 
Back
Top Bottom