Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Multiple forms and Multiple submit buttons and validation

Reply
Thread Tools

Multiple forms and Multiple submit buttons and validation

 
 
sandyde2
Guest
Posts: n/a
 
      10-01-2003
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
 
Reply With Quote
 
 
 
 
Lee
Guest
Posts: n/a
 
      10-01-2003
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)

 
Reply With Quote
 
 
 
 
sandyde2
Guest
Posts: n/a
 
      10-02-2003
Thanks, Lee !

You are sooo helpful !! Now the question solved !

with best wishes

sandy



Lee <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> 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)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Forms and submit buttons nettleby@googlemail.com HTML 12 04-17-2006 09:10 PM
Forms with multiple submit buttons vs 'form' objects with single 'submit' methods neil.fitzgerald@ic.ac.uk Python 4 04-14-2006 04:58 PM
How to programatically submit a form that uses document.forms[0].submit() Harry Ruby 3 01-12-2006 06:05 AM
Catching Submit Event even called by document.forms[0].submit() The Crow ASP .Net 2 09-27-2005 05:03 PM
Validation when there are two submit buttons Milton ASP .Net Web Controls 0 01-18-2005 12:23 PM



Advertisments