Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submit input field that uses an image as the button

Status
Not open for further replies.

michellerobbins56

Programmer
Jan 10, 2006
89
GB
Hi

I have a submit button input field for a form (called frmLogin) ...the code is as follows:
<input type="submit" name="btnLogin" value="Login">

This all works fine and I use the following code to determine if the submit button has been pressed on the page:
If Request.Form("btnLogin") <> "" Then ....

My plan is now to replace the basic submit button with an image. I am having trouble doing this. I have tried using
<input type="image".... but this does not work. I think the solution is using something like
onClick="document.frmLogin.submit();"
but I'm not sure how to implement this successfully as I find I cannot then use my earlier IF statement:
If Request.Form("btnLogin") <> "" Then ....
to tell if the button has been pressed (which is vital).

For some reason it can't work out if the button has been pressed or not.

How can I successfully use an image as the submit button and still carry on using my IF statement (so I can tell when the form submit button has been pressed)?

Thank you very much for any help.
 
You should be able to replace this:

Code:
<input type="submit" name="btnLogin" value="Login">

with this:

Code:
<input type="image" name="btnLogin" src="whatever.gif">

Your server-side code won't need to test to see if the submit button has been pressed, because the form won't be submitted until you do.

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
When you use image as submit button, instead of the name of the control name_x and name_y are sent with the coordinates as to where on the image you clicked. So you could check for the existance of those variables rather than just a name. It should work with that. You should inspect the whole Request.Form though to see the correct names of the variables.

Alternatively you could put your image inside the submit button as a background, put nothing in value and use width and height to make sure the background looks good on the element.
 
Thanks for your replies. I have used the latter option by putting an image as the background of the submit input field and putting &nbsp; in the value. This seems to work. Many thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top