How can you programatically submit a type image

J

jw56578

if i have an Input type Image
how am i suppose to programatically submit it through JS.

code:

<INPUT type="text"
onkeyup="javascript:if(event.keyCode==13){btnClick.click();}">

<INPUT name="btnClick" type="Image" value="Button"
onclick="javascript:alert('button was clicked');">

clicking "btnClick" will raise the onclick event producing 'button was
clicked', but onkeyup of the textbox will not call the click() method

Im using Input type Image because that is what ASP.net produces for an
image button.
 
K

kaeli

jw56578 said:
if i have an Input type Image
how am i suppose to programatically submit it through JS.

input type=image will automatically submit its form onclick.
<input type="image" name="whatever" src="myButton.gif" alt="submit">

No JS required.

The onclick is automatically script. Ditch the "javascript:".
onclick="somefunction();"

There is no such thing as submitting a button. If you want to submit the form
without clicking the button (from another form element handler), use
something like
onClick="this.form.submit();"

--
 
J

jw56578

That was no help, thanks. But I changed from onkeyup to onkeydown and
it worked, so nevermind.
 

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,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top