/    Sign up×
Community /Pin to ProfileBookmark

Form Submit Function

Here is the code to add a product to a 3rd party shopping cart.

<form action=”https://URL/cgi-bin/cart32.exe/username-
AddItem” method=”post” name=”formadd” id=”formadd”
onSubmit=”pageTracker._linkByPost(this)”>

The add to cart button to submit the form also has an onclick action as follows:

<input type=”button” value=”Add to Cart” name=”submitform”
onClick=”submitForm();” />

Currently only the onclick works.

Is there a way to rewrite it so both actions can take place?

Arny

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@toicontienJul 28.2008 — In the submiteForm() function, you need to call the onsubmit of the FORM. If the onsubmit returns false, do not submit the form. Otherwise, submit the form. Can we see the submitForm() function?
Copy linkTweet thisAlerts:
@firebladeJul 28.2008 — remove the[B][FONT="Courier New"][COLOR="Red"] onsubmit[/COLOR][/FONT][/B] from the [FONT="Courier New"][COLOR="Red"][B]<FORM>[/B][/COLOR][/FONT] tag. and insert the following line
[code=html]pageTracker._linkByPost(this)[/code]
in the last line of
<i>
</i>function submitForm() {
// your code goes here
pageTracker._linkByPost(this);
}
Copy linkTweet thisAlerts:
@toicontienJul 28.2008 — The "this" keyword refers to the the <FORM> and moving the function call breaks that relationship.
&lt;input type="button" value="Add to Cart" name="submitform"
onClick="[B]pageTracker._linkByPost(this.form); submitForm();[/B]" /&gt;
Copy linkTweet thisAlerts:
@Arny987authorJul 29.2008 — Okay,

I did what you said and the form submits, however, the GA is not showing up.

In order to get to the bottom of this, I have attached the very long code. See at the very bottom the submit button. The form will submit, but no GA.

Suggestions?

Arny

[upl-file uuid=80951fe4-296f-4bb1-81f0-d6a488bfba89 size=24kB]Javascript-analytics.txt[/upl-file]
Copy linkTweet thisAlerts:
@Arny987authorJul 31.2008 — Anyone know how to make this work?
×

Success!

Help @Arny987 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.29,
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,
)...