473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Multiple forms and Multiple submit buttons and validation

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
2 17160
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Red | last post by:
Hi, I'm not very familiar with Javascript. I usually leave that kind of stuff up to Dreamweaver, but i'm starting to need a little more than it can offer. I have an asp page which creates a...
3
by: D. Shane Fowlkes | last post by:
Sorry for the length of this post. I have created a rather complex form which has a header/line item (parent and child records) structure. It's for an intranet. A screenshot can be seen here: ...
8
by: TJS | last post by:
what are folks doing to get around limitation of one server form per page ?
5
by: excelleinc.com | last post by:
Hello, I have 2 forms to be filled by user, one is "auth" and second one contact form. They're completely independent. Problem is that when I enclose them within same <form runat="server"> tag...
3
by: Saket Mundra | last post by:
I have multiple web forms in my application. The user after logging on is directed to form1 where he enters information desired. Once finished he is directed to form2 and the same procedure goes on...
1
by: Bill_W_Stephens | last post by:
I have a complicated page with several submit buttons. I don't want to create multiple forms because much of the input is shared and the code is getting very ugly. However I would like to determine...
5
by: Alex Maghen | last post by:
In ASPX 2.0 with MasterPages and all that, my entire page only has one actual <FORM>. But there are several different sections of the page that provide what are functionally separate forms with...
5
by: c676228 | last post by:
Hi everyone, my colleagues are thinking about have three insurance plans on one asp page: I simplify the plan as follow: text box:number of people plan1 plan2 plan3
0
by: fperri | last post by:
Hi, I'm doing my first site in ASP.net. I have a form that has two list boxes where they can select a value in one and click a button to select and it moves it to the other listbox. I got this to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.