Here is the scenario, I have 3 html forms per page and they look like
form1 () form2 (form3 ())
dummy program to test three forms __
<script language="javascript" type="text/javascript"> function submitthisform(no){ document.forms[no].submit; } </script> <form action="http://cnn.com" name="1"> <input type=submit value="cnn" onclick="submitthisform('1')" name='submit1'> </form> <form action="http://google.com" name="2"> <form action="http://yahoo.com" name="3"> <input type=submit value="yahoo" onclick="submitthisform('3')" name="submit3"> </form> <input type=submit value="google" onclick="submitthisform('2')" name="submit2"> </form>
now when I do submit3, the onclick function is called, where I try to submit form3, because otherwise it always presents form 2
in onclick, I submit the form name. But form 3 seems unavailable. The reason is that if I cross all the forms on the page, it does not return form 3, but only form 1 and 2
var forms = document.getElementsByTagName("form"); for (var i=0; i<forms.length; i++){ alert('form'+i+' = '+forms[i].name);
it also gives javascript err on click submit2.
try this little code and you get this idea. tell me can i file form 3 !!!!
source share