Jump to content

Recommended Posts

Can anyone help me that how to convert an image to work as button.
Actually my question involve different issues.
I am making an online examination system in which in the admin area i have images instead of buttons for good look.  Lets say i have an image [b]Student[/b] Now when the student image (which will work as button) is clicked  i should be proceeded to the same page, with these different options.
Add Student
Delete Student
Edit Student
Update Student
Plz clarify me that in case of form buttons we make a hidden filed named let's say (h1) and then make its value to true and when that button is clicked, in the action of that form we provide the same file name, let's say student.php and then we have an isset() function and we check that either h1 form is submitted or other and then according to that form we write code.
So in case of images how can we handle such things.
I hope you get what i want to say  :-[
Thanx for any help in advance.
I think your question is asking how can you detect when an image is clicked as a form submit.  If that's the case, then what's actually passed by the form are the x and y co-ordinates of the point clicked relative to the top left corner of the image. For example, with this code in a form that uses the post method:

[code]<input type="submit" name="submit1" src="images/submit1.gif"/>[/code]

$_POST['submit1_x'] and $_POST['submit1_y'] will contain values when the submit1.gif image is clicked.
Yes that's exactly what i want , but i dont understand about the $_POST['submit1_x'] and $_POST['sumbit1_y'] . Will they contain information about the image X-axis and Y-axis values or something else ?
If you have worked with oscommerce, you can see that they have placed images instead of buttons . I want to create such thing.
[quote author=AndyB link=topic=109287.msg440371#msg440371 date=1159120971]
I think your question is asking how can you detect when an image is clicked as a form submit.  If that's the case, then what's actually passed by the form are the x and y co-ordinates of the point clicked relative to the top left corner of the image. For example, with this code in a form that uses the post method:

[code]<input type="submit" name="submit1" src="images/submit1.gif"/>[/code]

$_POST['submit1_x'] and $_POST['submit1_y'] will contain values when the submit1.gif image is clicked.
[/quote]

That do not work for me, but this does: [code]<button type="submit" name="submit1" style="border: 0px"><img src="images/submit1.gif" alt="button"></button>[/code]
[quote]
That do not work for me, but this does: [code]<button type="submit" name="submit1" style="border: 0px"><img src="images/submit1.gif" alt="button"></button>[/code]
[/quote]

Done. THankyou very much. Its now working with your code.
[quote author=onlyican link=topic=109287.msg440416#msg440416 date=1159123806]
[quote author=Barand link=topic=109287.msg440382#msg440382 date=1159121594]
or try

<input type="[color=red]image[/color]" name="submit1" src="images/submit1.gif"/>
[/quote]

That one works
That is the only one
[/quote]

Don't the one I showed work for you??
[quote author=Daniel0 link=topic=109287.msg440409#msg440409 date=1159123526]
Try this: [code]<button type="submit" name="submit1" style="border: 0px"><img src="images/submit1.gif" alt="button" onmouseover="this.src='images/submit1.gif'" onmouseout="this.src='images/submit2.gif'" ></button>[/code]
[/quote]

Rollover  Isn't Working
Here's the coding:

[code]<?
echo  "<form method=\"post\" action=\"mypage2.php\">
  <table width=\"200\" border=\"1\" align=\"center\">
    <tr>
      <td width=\"89\">Name : </td>
      <td width=\"95\">&nbsp;</td>
    </tr>
    <tr>
      <td>Age : </td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan=\"2\"><div align=\"center\">
//working fine    <button type=\"submit\" name=\"submit1\" style=\"border: 0px\"><img src=\"image012.gif\" alt=\"button\"></button>
//working fine        <input type=\"image\"  src=\"image012.gif\">
//rollover not working <button type=\"submit\" name=\"submit1\" style=\"border: 0px\"><img src=\"image012.gif\" alt=\"button\" onmouseover=\"this.src='image012.gif'\" onmouseout=\"this.src='image002.gif'\" ></button>
      </div></td>
    </tr>
  </table>
</form>";

?>[/code]
no
The only way to make a button an image is
<input type='image'' name='submit'..

Why make things more complex, the code is there ready made
and with that way
you can use
$_POST["submit_x"] and $_POST["submit_y"] for the X and Y position of the click
If you want
The advantage of
<input type='image' src='image012.gif' name='student'>

is that (as has pointed out several times now) it post values in $_POST['student_x'].

You can use this to find out which of your buttons was clicked.

[code]
if (isset($_POST['student_x'])) {
    // student button was clicked
}
elseif (isset($_POST['other_x'])) {
    // other button was clicked
}[/code]

With Daniels code, the image tag contents are posted.
[quote author=Barand link=topic=109287.msg440429#msg440429 date=1159124880]
The advantage of
<input type='image' src='image012.gif' name='student'>

is that (as has pointed out several times now) it post values in $_POST['student_x'].

You can use this to find out which of your buttons was clicked.

[code]
if (isset($_POST['student_x'])) {
    // student button was clicked
}
elseif (isset($_POST['other_x'])) {
    // other button was clicked
}[/code]

With Daniels code, the image tag contents are posted.
[/quote]

Now things are cleared to me. Thats what i finally want. Once again thankyou very much for all of you.
[quote author=Barand link=topic=109287.msg440440#msg440440 date=1159125817]
As for the rollover
[code]
<input type='image' name='student' src='image1.gif'
    onmouseover='this.src="image2.gif"'
    onmouseout='this.src="image1.gif"'>
[/code]
[/quote]

BINGO, ITS WORKING
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.