submit button with image question

M

Matt

In the following code, I have 2 questions regarding submit button with
image.

1) Does this code <input type="image" name="populate" src="populate.gif">
behave the same as an HTML submit button with image populate.gif?
When I click p1 or p2 button, it will post the page to process.asp.

2) When I check the checkbox, I want the image in submit button change
from populate.gif to validate.gif. Unfortunately, the code
InputForm.p2.src = "validate.gif"; doesn't work. But
InputForm.p1.value = "validate button"; is working for a regular HTML submit
button.

Any workarounds? Please advise. Thanks!!

<html>
<head>
<script type="text/javascript">
function cb_onClick()
{ if (InputForm.C1.checked == true) //NOT InputForm.C1.value == "on"
{
InputForm.p1.value = "validate button";
InputForm.p2.src = "validate.gif";
}
else
{
InputForm.p1.value = "populate button";
InputForm.p2.src = "populate.gif";
}
}
</script>
</head>
<body>
<form name="InputForm" method="POST" action="process.asp">
<p><input type="checkbox" name="C1" onClick="cb_onClick()"></p>
<p><input type="submit" name="p1" value="populate button">
<p><input type="image" name="p2" src="populate.gif">
</form>
</body>
</html>
 
B

Bullschmidt

No but here's a workaround that has worked for me:

<input type="image" src="myimage.gif"
onclick="document.frmMain.ButtonName.value =
'btnProcess';document.frmMain.submit();">

Best regards,
J. Paul Schmidt, Freelance ASP Web Designer
http://www.Bullschmidt.com
ASP Designer Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
B

Bullschmidt

<<
But how to change the image?
Well if you're posting to the same page then perhaps change this:
<input type="image" src="myimage.gif"
onclick="document.frmMain.ButtonName.value =
'btnProcess';document.frmMain.submit();">

To be more like this instead:
<input type="image" src="<%= ImageNameVariable %>"
onclick="document.frmMain.ButtonName.value =
'btnProcess';document.frmMain.submit();">

Otherwise perhaps ask on a JavaScript or DHTML board...

Best regards,
J. Paul Schmidt, Freelance ASP Web Designer
http://www.Bullschmidt.com
ASP Designer Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,273
Latest member
DamonShoem

Latest Threads

Top