![]() |
How to pass my form ID to a function that runs onsubmit?
Hi all,
I have 2 separate forms that I would like to execute the same function on, but only on one of them when the form is submitted. The function will manipulate the input field of only the form which was submitted. Here's what I'm working with now: Form Code: Code:
<form method="post" id="newsletter_signup_footer" onsubmit="newsletterSubmit(newsletter_signup_footer);">Code:
$(document).ready(function(){ onsubmit="newsletterSubmit(newsletter_signup_footer);" Which I want to run the function on submit. And I'm passing the ID of the form to that function I'm calling.When I hit submit on that form I get an error message though: Uncaught ReferenceError: newsletterSubmit is not defined Any idea what I'm doing wrong?? |
Two major problems
1 - You are defining jQuery.fn.newsletterSubmit. This will turn the method newsletterSubmit() into a plug-in that should be called as a method of a jQuery object. Something in the lines ofCode:
$('#newsletter_signup_footer').newsletterSubmit();If you don't want a plug-in, you can define newsletterSubmit() as a normal function Code:
function newsletterSubmit(newsletterForm) {Code:
onsubmit="newsletterSubmit('newsletter_signup_footer');" |
| All times are GMT +1. The time now is 06:16 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.