0

<input id="aaa" onclick="scrollTo('registerBox'); return false;" formaction="register.php" type="submit" value="Register" />

If JavaScript is enabled (which it is, and it's working on other functions and triggers). Shouldn't it execute scrollTo("registerBox"); and don't do anything (return false;).
Am I missing something? I don't want it to formaction if JavaScript is enabled.

3
Contributors
3
Replies
80
Views
9 Months
Discussion Span
Last Post by gentlemedia
0

There you go now type in the body area this not in the script tags
make a function that returns ot not just a button i know you returned false and that might be why and also i did not heard of formaction ( i am learning JavaScript)

     <input onClick=" return 'Hey!'" formaction="register.php" type="submit" value="Register"/>
0

Sorry, but your snippet returns 'Hey!', I don't need it to return anything, I need it to execute mentioned function and return nothing.
That answer doesn't bring me closer to expectations.

And without punctionation and seperation it's hard to get by what you mean with "There you go now type in the body area this not in the script tags make a function that returns ot not just a button i know you returned false and that might be why".

Edited by Aeonix

3

For starter I'd recommend to take out the onclick attribute from the HTML. Keep structure and behavior seperate.

<input id="aaa" formaction="register.php" type="submit" value="Register" />

And then within <script> tags

document.getElementById('aaa').addEventListener('click', function (e) {
    e.preventDefault();
    // scrollTo here
});

or with jQuery

$('#aaa').on('click', function (e) {
    e.preventDefault()
    // scrollTo here
})
Votes + Comments
I guess it's better practice, than to skip back and forth.
Agreed
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.