Jump to content

Forms Wiggin Out


cavey5

Recommended Posts

This is a simple html question. I am using images as form elements but when I do, it wigs out my table spacing. I guess I can use DIV tags but I am curious to solve this with html tables.

My code with forms:

[pre]
echo "
<tr>
<td width=\"20\" height=\"20\" align=\"left\" valign=\"middle\"><font class=\"cart\">&nbsp;&nbsp;($qty)</font></td>
<td width=\"180\" height=\"20\" align=\"left\" valign=\"middle\"><font class=\"cart\">&nbsp;&nbsp;$description</font></td>
<td width=\"70\" height=\"20\" align=\"right\" valign=\"middle\"><font class=\"cart\">$itemtotal</font></td>
<td width=\"25\" height=\"20\" align=\"right\" valign=\"middle\">
[color=red]<form name=\"add_one_item\" method=\"post\" action=\"add_one_item.php\">
<input type=\"image\" name=\"plusmark\" src=\"images/main/plus.jpg\">
</form>[/color]
</td>
<td width=\"25\" height=\"20\" align=\"left\" valign=\"middle\">&nbsp;&nbsp
[color=red]<form name=\"rem_one_item\" method=\"post\" action=\"rem_one_item.php\">
<input type=\"image\" name=\"minusmark\" src=\"images/main/minus.jpg\">
</form>[/color] </td>
</tr>
";
}
echo "
<tr>
<td width=\"320\" height=\"6\" bgcolor=\"#639B38\" colspan=\"5\"></td>
</tr>
<tr>
<td width=\"320\" height=\"1\" bgcolor=\"#000000\" colspan=\"5\"></td>
</tr>[/pre]


Here is what it looks like when there are no forms, just unlinked images (the "+" and "-" are small jpgs):

[img]http://www.timbercrawler.com/tim/screenshots/sc_ok.jpg[/img]


And here is it when I insert the forms:


[img]http://www.timbercrawler.com/tim/screenshots/sc_notok.jpg[/img]

Any ideas what I can do to bring it all back in line?


Link to comment
https://forums.phpfreaks.com/topic/18969-forms-wiggin-out/
Share on other sites

Just as a matter of interest, why are you even using forms for those, when you could just as well use a standard href link acting the same way as a form with the method GET.  Just change the two scripts that the form posts to so they'll accept a GET via clicked image.  There's no data passed by the form, so a link's as good and simpler.

[code]<form name=\"add_one_item\" method=\"post\" action=\"add_one_item.php\">
<input type=\"image\" name=\"plusmark\" src=\"images/main/plus.jpg\">
</form>[/code]

Is functionally equivalent to this:

[code]<a href='add_one_item.php'><img src='images/main/plus.jpg' ...></a>[/code]
Link to comment
https://forums.phpfreaks.com/topic/18969-forms-wiggin-out/#findComment-82014
Share on other sites

actually I do have some hidden fields that are being passed; they just were not in my code snippet. I cannot use just an ahref because I cannot pass php variables that way.

<td width=\"10\" height=\"20\" align=\"left\" valign=\"top\">
<form name=\"rem_one_item\" method=\"post\" action=\"rem_one_item.php\">
<input type=\"hidden\" name=\"productid\" value=\"$productid\">
<input type=\"hidden\" name=\"qty\" value=\"$qty\">
<input type=\"image\" name=\"minusmark\" src=\"images/main/minus.jpg\">
</form>
</td>
Link to comment
https://forums.phpfreaks.com/topic/18969-forms-wiggin-out/#findComment-82017
Share on other sites

The inherent line break with a form was removed through the styling I suggested and you adopted.

You still son't need a form as you can pass data with the URL link like so - just modify add_one_item.php to abstract from the $_GET array, not the $_POST array.

[code]<a href='add_one_item.php?productid=". $productid. "&qty=". $qty. "'><img src='images/main/plus.jpg' ...></a>[/code]
Link to comment
https://forums.phpfreaks.com/topic/18969-forms-wiggin-out/#findComment-82020
Share on other sites

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.