didgydont Posted April 27, 2008 Share Posted April 27, 2008 hi all i was just wondering how i can make it so when you click on the image it submits the item number to the item.php page and instead of a button can i make the submit button just a link ? <html> <head> <title>OLD WORLD</title> <link rel="stylesheet" type="text/css" href="site.css" /> <body> </head> <body> <?php include("connect.php"); include("toolbar.php"); echo "<h1 ALIGN=\"center\">Old World Chandliers</h1>"; $result = mysql_query("SELECT * FROM stock"); // $result = mysql_query("SELECT * FROM stock WHERE itemnumber='$itemnumber'"); while($row = mysql_fetch_array($result)) { $itemnumber = $row['itemnumber']; $name = $row['name']; $image = $row['image']; echo "<table border='0' ALIGN='center' cellpadding='5' cellspacing='0'><tr>"; echo "<td><a href='$image'><img src='$image' alt='$name' width='200' height='170'></a> </td><td><form action=\"item.php\" method=\"post\" width=\"200\"> <input type=\"hidden\" name=\"itemnumber\" value=\"$itemnumber\"> <input type=\"submit\" VALUE=\"$name\" class=namesbtn> </form></td></tr></table>"; } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/103100-solved-click-on-image-to-submit-to-form/ Share on other sites More sharing options...
Fadion Posted April 27, 2008 Share Posted April 27, 2008 Give the image a link like: item.php?id=xx and use $_GET to capture the id variable. For the submit link, assign an ID to the form (ex: id="myForm") and use the following: <a onClick="document.myForm.submit();" href="#"> Link to comment https://forums.phpfreaks.com/topic/103100-solved-click-on-image-to-submit-to-form/#findComment-528134 Share on other sites More sharing options...
didgydont Posted April 27, 2008 Author Share Posted April 27, 2008 thank you i am still a noob Link to comment https://forums.phpfreaks.com/topic/103100-solved-click-on-image-to-submit-to-form/#findComment-528154 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.