By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,036 Members | 978 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,036 IT Pros & Developers. It's quick & easy.

Multiple forms and Multiple submit buttons and validation

P: n/a
Hi all,

I get the tough problem and expect to get help..

In a html page, I dynamically created many forms which named as
NO+business_id. In each form there are two submit buttons to
"release_or_not". of course in the server side I validate those values
as well. However, because this page is for admin to use so that I do
not need to care any hacker action. Hence, in the client side
javascript I validate those values and give it a popup report window
to confirm.

Now the problem comes. The javascript does not know which button I
clicked. Therefore I make a onclick function in setAction
<input type="submit" value="Release" name="release_or_not"
onClick="return setAction(1)">
<input type="submit" value="Reject + Delete Entry"
name="release_or_not" onClick="return setAction(2)">
and a hidden variable called ddd
<input type="hidden" name="ddd" value="" >

after clicking a submit button, it calles the setAction function
before onsubmit isValid function of the form. In setAction function, I
want to set the hidden ddd variable to "Release" or "Reject + Delete
Entry", so that it is the alternative way for the validation function
to know which submit button I clicked.
function setAction(act)
{
if(act == 1)
{
x.ddd.value = "Release";
return true;
}
else if(act == 2)
{
x.ddd.value = "Reject + Delete Entry";
return true;
}
else
{
return false;
}
}

as you see, currently I do not know in which form it is. I ever create
the setAction(this,1).. and expect "this" can be the form.. but
failed..

I have no idea now.. any comment will be greatly appreciated..

with best wishes

sandy
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Lee
sandyde2 said:
as you see, currently I do not know in which form it is. I ever create
the setAction(this,1).. and expect "this" can be the form.. but
failed..


Since setAction(this,1) is in the onClick handler of the submit button,
the "this" refers to the button. Fortunately, every form element has
an attribute named "form" which is a reference to the form which
contains it:

setAction(this.form,1)

Jul 20 '05 #2

P: n/a
Thanks, Lee !

You are sooo helpful !! Now the question solved ! :D

with best wishes

sandy

Lee <RE**************@cox.net> wrote in message news:<bl********@drn.newsguy.com>...
sandyde2 said:
as you see, currently I do not know in which form it is. I ever create
the setAction(this,1).. and expect "this" can be the form.. but
failed..


Since setAction(this,1) is in the onClick handler of the submit button,
the "this" refers to the button. Fortunately, every form element has
an attribute named "form" which is a reference to the form which
contains it:

setAction(this.form,1)

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.