Forum Moderators: open

Message Too Old, No Replies

Rollover Image Submit button won't proceed with Enter

         

pinokiyo

8:27 am on Jul 19, 2004 (gmt 0)

10+ Year Member



I'm using rollover image for a submit button for a form that has Username and password.

The rollover works but it'll show the ordinary submit button as well!

I could set the input to "hidden" for the ordinary one but then if i do that, it won't proceed if I just hit Enter. I have to click on the image submit button!

This is the code I'm using for the rollover submit button...

[idocs.com...]

RonPK

12:56 pm on Jul 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your script probably ignores the enter key because it needs the script to fire the submit event. The script is only run when someone clicks the button. That is no good.

Why not use an ordinary roll on - roll off script and attach it to the <input type="image">-button?


but_on = new Image(); but_off = new Image();
but_on.src = "but_on.png";
but_off.src = "but_off.png";
function togglepix(pic, t) {
if (document.getElementById) {
document.getElementById(pic).src = (t? but_on.src : but_off.src);
}
}

/-/-/-/-/-/-/-/-/-/-/-/

<input type="image" src="but_off.png" id="mybutton"
onmouseover="togglepix(\'mybutton\', 1); return true"
onmouseout="togglepix(\'mybutton\', 0); return true">

pinokiyo

9:49 am on Jul 21, 2004 (gmt 0)

10+ Year Member



Sorry but I'm not very good with Javascript.

Where does the first code go? I add it with <SCRIPT TYPE="text/javascript"> right?

This is what I did..

<SCRIPT TYPE="text/javascript">
<!--
but_on = new Image(); but_off = new Image();
but_on.src = "login_on.jpg";
but_off.src = "login.jpg";
function togglepix(pic, t) {
if (document.getElementById) {
document.getElementById(pic).src = (t? but_on.src : but_off.src);
}
//-->
</SCRIPT>

<input type="image" onSubmit="this.form.action.value='login'" name="Login" value="Login" src="login_on.jpg" id="mybutton"
onmouseover="togglepix(\'mybutton\', 1); return true"
onmouseout="togglepix(\'mybutton\', 0); return true">

I get an error though.

RonPK

1:26 pm on Jul 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry, I should re-read my stuff before posting...

The backward slashes in the togglepix function are very wrong. Try
togglepix('mybutton', 1);
and
togglepix('mybutton', 0);

Another thing is that there have to be 2 closing brackets in the script: one to close the function, and one to close the if-statement. So it should end like this:

document.getElementById(pic).src = (t? but_on.src : but_off.src);
}
}
//-->
</SCRIPT>

pinokiyo

2:50 am on Jul 22, 2004 (gmt 0)

10+ Year Member



Nice! It worked! It's much better now. Thank you so much.