Forums

Looking for a simple example of some javascript on submit

shaneblaser 07 Feb, 2013
We have a form we need to do a little js processing, I dragged cusmto code into the on submit.

I am not get a simple alert("test") to display

Sample much appreciated

Shane
GreyHead 07 Feb, 2013
Hi Shane,

Please see this FAQ

Because JavaScript runs in the browser when the form loads you will almost always load it on the On Load event.

Bob
shaneblaser 07 Feb, 2013
I need to run the code on submit, how would I do that? I see the example but it is not clear to me how to run on submit ..
GreyHead 08 Feb, 2013
Hi shaneblaser,

If you want it to run when the submit button is clicked then give the submit button an id like submit_btn and use JavaScript like this:
window.addEvent('domready', function() {
  $('submit_btn').addEvent('click', function() {
    // add your script here
  });
});

Bob

Bob
This topic is locked and no more replies can be posted.