Submit Form by clicking on an image

I

Ice Man

Hi all

How Can I submit a form by clicking on an image instead of the submit
button?

Thanks
 
E

Elie Grouchko

Use JavaScript code that will submit the form as a result of the click
event:

<html>
<head>

<script type="text/javascript">
function SubmitForm()
{
document.getElementById("form1").submit();
}
</script>

</head>
<body>

<form id="form1" action="page2.htm" method="post">

<img src="" onclick="SubmitForm()">

</form>

</body>
 
S

Stuart Palmer

Elie Grouchko said:
Use JavaScript code that will submit the form as a result of the click
event:

<html>
<head>

<script type="text/javascript">
function SubmitForm()
{
document.getElementById("form1").submit();
}
</script>

</head>
<body>

<form id="form1" action="page2.htm" method="post">

<img src="" onclick="SubmitForm()">

</form>

</body>

Why don't you just use:

<input type="image" src="image.jpg" alt="Submit" height="50" width="50" />

Then the form will submit for JS user and non JS users alike.....BTW, how
long has ASP been clientsize javascript?

:eek:/
 
B

Bã§TãRÐ

The image actually works like a submit button when using

<input type="image" name="subButton" src="image.jpg" alt="Submit"
height="50" width="50" />

getting the value from the submit button is
request.form("subButton.x") OR
request.form("subButton.y")

Because the button is an image - you are esentially testing to see if
the x,y value (height, width) is greater than 0

Hope this help
- Bastard
 

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

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,190
Latest member
ClayE7480

Latest Threads

Top