Bug Tracker

Opened 11 years ago

Closed 11 years ago

#4614 closed bug (invalid)

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 (last modified by brandon)

<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.

Change History (2)

comment:1 Changed 11 years ago by brandon

Description: modified (diff)

comment:2 Changed 11 years ago by brandon

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

Note: See TracTickets for help on using tickets.