/    Sign up×
Community /Pin to ProfileBookmark

submit Two html forms with one javascript onclick event with Chrome

I have a web page with two forms, when I click the button on one of the forms, the onclick event goes to a javascript that emails the first form and then the second form. This is correct, this is the way I want this to work. It’s simple, it’s easy, it works!
However, it only works in FireFox and Internet Explorer, it will not work in Google Chrome browser.

[CODE]<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=windows-1250″>
<title></title>
</head>
<body>
<form id=”NameForm” method=”post” action=”mailto:[email protected]”>
Name: <input type=”text” size=”10″ name=”name”> <br />
<input onclick=functionCaller() type=”button” value=”Submit Two Forms”>
</form>

<form id=”AddressForm” name=”DComments” method=”post” action=”mailto:[email protected]”>
Address: <input type=”text” size=”10″ name=”address”> <br />
</form>
<script type=”text/javascript”>
<!–
function functionCaller()
{
document.getElementById(‘NameForm’).submit();
document.getElementById(‘AddressForm’).submit();
}
–>
</script>
</body>
</html>[/CODE]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@SikoSoftApr 14.2011 — The first thing I notice is the call to the javascript function (the value for onclick) isn't even quoted...

Modern browsers seem to be a lot less forgiving to quirky markup, so I'd suggest trying that... if all else fails validate the document to see what else is wrong.

Hope this helps!
Copy linkTweet thisAlerts:
@RCguaauthorApr 14.2011 — thanks, for noticing, I changed the line below but it still works fine in IE and FF but not Chrome. I will validate (again) and fix any other errors.

[CODE]<input type="button" onclick="functionCaller()" value="Submit Two Forms"> [/CODE]
×

Success!

Help @RCgua spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...