Results 1 to 10 of 10
  1. #1

    Image buttons don't work onclick.

    This is the original code for the standard form buttons, which works perfectly.

    <input type=submit class=submitclass name=button value="Back" onclick="javascript:history.back();">

    <input type=submit class=submitclass name=add value='Add' onclick="return color_check()";>

    However, I want the buttons to be rendered as images, so I did this:

    <input type=image src="back.gif" name=submit value=Back onclick="javascript:history.back();">

    <input type=image src="add.gif" name=submit value=Add onclick="return color_check()";>

    The image buttons don't seem to do anything when clicked. What am I doing wrong here?

  2. #2
    Join Date
    May 2004
    Omaha, NE

    Talking wild guess

    I think you still need the submit

    I would try something like this but it is just a guess.

    <input type=image class=submitclass src="back.gif" name=submit value=Back onclick="javascript:history.back();">

    <input type=image class=submitclass src="add.gif" name=submit value=Add onclick="return color_check()";>

    Let me know if it works

  3. #3
    Thanks for the suggestion. I tried adding class=submitclass to each clause and it still didn't work.

  4. #4
    Join Date
    Mar 2004
    The image buttons as you wrote should work perfectly...

    I tested it and it worked...

    check ur settings again.
    Testing 1.. Testing 1..2.. Testing 1..2..3...

  5. #5
    Thanks azizny... I agree they should work but somehow they don't... I literally cut and paste the latter with the former and it stops working...

    What settings should I check?

  6. #6
    Join Date
    Mar 2004
    is the picture in the same directory?

    Its a stupid question but some people forget

  7. #7
    heh, yeah, the pics are in the right directory. The pictures are displayed correctly. It's just that when clicked, they don't work. What's odd is that I've used the same code in other pages and it works...

    This has me stumped.

  8. #8
    Join Date
    Aug 2003
    Is your browser window freshly opened? Meaning, have you come to that test page from another page? Just wondering...


  9. #9
    voltrader: are you using Internet Explorer?

    If you are using Netscape 6.0, then the images don't work, since Netscape, Mozilla, and older browsers do not support the onClick, onMouseOver, and onMouseOut method for images. Try this instead:

    <a href="#" onClick="javascript:history.back();" style="border: 0px;">
    <input type=image src="back.gif" name=submit value=Back ></a>

    <a href="#" onClick="return color_check();" style="border: 0px;"><input type=image src="add.gif" name=submit value=Add> </a>

    This hides the border of the hyperlink, forces an action, and produces the same effect as it would in IE.

    As usual, I hope this is helpful.
    IM: tweak1870

  10. #10
    Join Date
    Mar 2004
    Mozilla doesnt support those!?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts