View Full Version : Quick onClick Question

04-28-2008, 03:55 PM
Hi guys,

It's probably just bad syntax, but what is wrong with this? I've chopped it and tried it using document.forms.formName and document.formName... Need a quick hand...:

<A HREF="http://ww.address.com/index.php?page=2" onclick="document.MainForm.submit();">Next Page</A>

Doesn't submit the data... I've copied the syntax verbatim from tutorials... Nothing seems to work...


04-28-2008, 04:04 PM
Why do you need a link to submit the form instead of usual input type="submit"

04-28-2008, 10:21 PM
if you have an input type=file in there, then it won't work.
otherwise try document.form.submit(); or document.forms[0].submit(); or give your form an id instead of a name and use document.getElementById("my_forms_id").submit();

04-29-2008, 03:52 AM
Thanks to you both, particularly mjlorbet - I will try that to see if it makes a difference but I have just reailsed that if it does fix it, it won't resolve the bigger problem. I am taking the wrong path...


04-29-2008, 05:15 AM
I think you have an issue that the link is executing. You need to add return false to the end of the onclick. With the way you have it coded, it is a race to see if the form or if the link executes first.


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum