/    Sign up×
Community /Pin to ProfileBookmark

Calling a function selectively

I have a Javascript function that I call in my form submit, which validates the form. It looks like this:

<form name=”form” method=”post” action=”process.cfm” onSubmit=”Validate(this);return false”>

It works fine, but I also want to be able to have a Save As Draft button, which would create a record in the db but would not validate the form. Can I selectively call this function only if they click Submit and not Save As Draft? I’ve tried calling it in the Submit button itself as an onClick, but I get errors when I do it this way.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@scragarJan 07.2005 — <form name="frm1" method="post" action="process.cfm">

<input type=submit name=Subtype

onclick="return Validate(document.frm1);"

value="Submit">

<input type=submit name=Subtype

value="Save Draft">


all you'll have to do is ensure Validate returns true for sucsess and false for failure so the submission stops or goes as apropriate.

when you read the submission check the value of Subtype in the querysting, it's either "Save Draft" or "Submit".
Copy linkTweet thisAlerts:
@drudiggyauthorJan 07.2005 — Perfect, thank you!

I'm sorry, too, BTW. RIP. ?
Copy linkTweet thisAlerts:
@scragarJan 07.2005 — I only just figgured out why you posted that last bit even though I've been looking at it since you first posted it.

Did you know theres an aceptedApoligies site somewhere and some other deviations as well.
Copy linkTweet thisAlerts:
@drudiggyauthorJan 07.2005 — Yeah, it's [URL=http://www.apologiesaccepted.com/index.html]http://www.apologiesaccepted.com/index.html[/URL]. A great site!
×

Success!

Help @drudiggy 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.25,
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,
)...