JavaScipt

Soldato
Joined
2 Oct 2003
Posts
2,843
Location
MI5 | Thames House
Trying to use a Img instead of the crappy look grey button code 1 work's fine but my code in 2 doesnt any ideas, sorry inadvance ;) . Iv'e googled and my code looks fine:confused:

1
Code:
<tr><td><center><input type="button" value="Login" onClick="pasuser(this.form)">
2
Code:
<tr><td><center><input type="image" img src="login.png" onClick="pasuser(this.form)">
 
Last edited:
That random "img" attribute floating around in the tag might be causing the problem.
 
Just use CSS or JS to target the button?

edit: If you can post a link that'd be handy.
 
Last edited:
The problem is because the input type="image" will submit the form before it runs any code you put in the onclick handler, and because the form submission causes a redirect, the onclick code will never be run.

You either need to change the input to an image with the click handler on it (and make sure you also call form.submit() in there), or remove the click handler from the image input and add an onsubmit handler to the form.
 
The problem is because the input type="image" will submit the form before it runs any code you put in the onclick handler, and because the form submission causes a redirect, the onclick code will never be run.

You either need to change the input to an image with the click handler on it (and make sure you also call form.submit() in there), or remove the click handler from the image input and add an onsubmit handler to the form.

sorted thanks for the help m8 , :D
Code:
<a href="JavaScript:pasuser(form)"> <img src="login.png"</a>
 
Last edited:
Use the button element instead

Code:
<button onclick="pasuser(this.form)">Yo!</button>

And if that is submitting your form, move it to the onSubmit of the form itself and just add type attribute of submit to the button ie:

Code:
<form onsubmit="pauser(this.form)">
<button type="submit">Yo!</button>
</form
 
Back
Top Bottom