Page 1 of 1
Input Type = Image
Posted: Fri Aug 05, 2011 8:16 pm
by Tim
Hmm, any idea why this code won't work in Firefox and Internet Explorer, but works in Chrome just fine?
Code: Select all
<?php
if (isset($_POST['harvestable']))
{
echo "Success!";
}
?>
<form action="harvest.php" method="post">
<table border ="0" cellspacing="50">
<tr>
<td><center><input type="image" name="harvestable" value="Blue Lupine" src="/images/items/blue_lupine.png"><br>Blue Lupine</center></td>
</tr>
</table>
</form>
Or is there another way I can have this work?
I think it's about time I start digging into Jquery ... Advice?
Thank you!
Re: Input Type = Image
Posted: Fri Aug 05, 2011 8:23 pm
by Xaleph
Well, the code is just messed up, that`s why it doesn`t work.
First of, close an input type image propery using the /> self closing tag. Second, an input type image doesn`t need a value ( you are using an image remember ? ) and lastly, don`t use <center>. It`s old, if you want something aligned, use css ( text-align: center; )
Re: Input Type = Image
Posted: Fri Aug 05, 2011 8:27 pm
by Tim
Thanks for the fast reply.
I need a value because that's how I'm going to retrieve everything out of the database.
Code: Select all
<?php
if (isset($_POST['harvestable']))
{
$harvestable_name = $_POST['harvestable'];
$harvestable_info_1 = "SELECT * FROM items WHERE name = '$harvestable_name'";
$harvestable_info_2 = mysql_query($harvestable_info_1) or die ("System: Unable to retrieve harvestable information.");
$harvestable_info_3 = mysql_fetch_array($harvestable_info_2);
}
?>
<form action="harvest.php" method="post">
<table border ="0" cellspacing="50">
<tr>
<td><input type="image" name="harvestable" value="Blue Lupine" src="/images/items/blue_lupine.png" /><br>Blue Lupine</td>
</tr>
Re: Input Type = Image
Posted: Fri Aug 05, 2011 8:32 pm
by Xaleph
Use input type submit
In your css you can style the button to use an image as well. Jut give it a class or id and in your css:
#someID , .someClass {
height: (height of your image)px;
width: (width of your image)px;
background-image: url(the_url_to_the_image);
text-indent: -9999px;
}
Anyway, value is possible, but why use it like that? In a submit button ( image) ? Maybe use a input type="hidden" to give that sort of information.