WoW Gold - Find jobs - PT Cruiser - Find services - Property in Estonia

PDA

View Full Version : Submit HTML form with javascript


NoamBarz
Feb 15th 2009, 11:41 pm
Hi

I have a form with the action attribute set to a javascript function (action="javascript:DoSomething();"). In my function, after checking that the data was entered properly, I want to submit the form.

I use something like this:

var frm = document.frm; (my form)
if(frm){
frm.action = 'newpage.php';
frm.submit();
}

There's nothing wrong with this code except that in chrome, nothing happens after I click the submit button for the first time. The form submits only after the second click.

Any ideas why?

dimitar christoff
Feb 16th 2009, 2:21 am
dunno - try adding an alert before and after the if (frm) to see if it sets the object or not. to be honest, try accessing it via id - var frm = document.getElementById("myform");

ranacseruet
Feb 16th 2009, 2:45 am
i think
this.formname.submit()
should work fine..