Thursday, December 3, 2009

javascript submitting form twice

I have form with hidden fields. When i do change the country select box, taking the value of select box  & updating  the same in hidden field. When i hit the search button to search countries, i am submitting the form using javascript.

My code:

<a href="#" onclick="submitMyForm();">Search</a>

I was wondering this javascript submitted this form twice. First time with the value in the hidden box and second time with out.

We found out the problem with my javascript code. 

Correct code:

<a href="#" onclick="submitMyForm();return false;">Search</a>

So "return false;" did trick for me.

Have fun

0 comments:

Post a Comment