Skip to main content

Bug Tracker

Side navigation

#4614 closed bug (invalid)

Opened May 01, 2009 02:40AM UTC

Closed May 05, 2009 11:29PM UTC

submit bug?

Reported by: jpxavier Owned by: brandon
Priority: major Milestone: 1.4
Component: event Version: 1.3.2
Keywords: submit Cc:
Blocked by: Blocking:
Description
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(function() {
	$("#f1_submit").click(function(){
		$("form:form1").submit();
	});
	$("#f2_submit").click(function(){
		$("form:form2").submit();
	});
	$("#f3_submit").click(function(){
		document.form1.submit();
	});
});
</script>
</head>
<body>
	<form name="form1" action="jq.html#test1" method="post">
	</form>
	<a id="f1_submit" href="#">Form1</a></br>
	<form name="form2" action="jq.html#test2" method="post">
	</form>
	<a id="f2_submit" href="#">Form2</a></br>
	<a id="f3_submit" href="#">Form2</a></br>
</body>
</html>

the submitted form always takes the action of the second form? Clicking on f1_submit never submits the first form. but click on f3_submit works fine.

Attachments (0)
Change History (2)

Changed May 05, 2009 11:22PM UTC by brandon comment:1

description: <html> \ <head> \ <script type="text/javascript" src="jquery.js"></script> \ <script type="text/javascript"> \ $(function() { \ $("#f1_submit").click(function(){ \ $("form:form1").submit(); \ }); \ $("#f2_submit").click(function(){ \ $("form:form2").submit(); \ }); \ $("#f3_submit").click(function(){ \ document.form1.submit(); \ }); \ }); \ </script> \ </head> \ <body> \ <form name="form1" action="jq.html#test1" method="post"> \ </form> \ <a id="f1_submit" href="#">Form1</a></br> \ <form name="form2" action="jq.html#test2" method="post"> \ </form> \ <a id="f2_submit" href="#">Form2</a></br> \ <a id="f3_submit" href="#">Form2</a></br> \ </body> \ </html> \ \ the submitted form always takes the action of the second form? Clicking on f1_submit never submits the first form. but click on f3_submit works fine.{{{ \ <html> \ <head> \ <script type="text/javascript" src="jquery.js"></script> \ <script type="text/javascript"> \ $(function() { \ $("#f1_submit").click(function(){ \ $("form:form1").submit(); \ }); \ $("#f2_submit").click(function(){ \ $("form:form2").submit(); \ }); \ $("#f3_submit").click(function(){ \ document.form1.submit(); \ }); \ }); \ </script> \ </head> \ <body> \ <form name="form1" action="jq.html#test1" method="post"> \ </form> \ <a id="f1_submit" href="#">Form1</a></br> \ <form name="form2" action="jq.html#test2" method="post"> \ </form> \ <a id="f2_submit" href="#">Form2</a></br> \ <a id="f3_submit" href="#">Form2</a></br> \ </body> \ </html> \ }}} \ \ the submitted form always takes the action of the second form? Clicking on f1_submit never submits the first form. but click on f3_submit works fine.

Changed May 05, 2009 11:29PM UTC by brandon comment:2

resolution: → invalid
status: newclosed

Your selectors are incorrect. Give your forms an id that is the same as the name and just use the id.

Instead of:

 $("form:form1").submit(); 

Do this:

 $("#form1").submit(); 

Or if you want to stick to the name attribute:

 $("form[name=form1]").submit(); 

Selector docs: http://docs.jquery.com/Selectors