473,473 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

detecting submit control in Javascript

Hi all,

Looking for a bit of help with this one...I have a situation where I
need to be able to determine the control that initiated a form's submit
action in client-side Javascript. I am currently calling a Javascript
function on the client-click that returns true/false to control the
submission of a product, but I am now trying to implement functionality
to disable the buttons after the initial click, but continue with the
submit operations. My form is a mixture of HTML and .NET controls, so
I'm wondering if there is a generic way to determine in Javascript what
control actually caused my validation function to be invoked, short of
having to pass the control as part of the argument list - I am trying
to get a generic solution not requiring that level of modification.

Of note here is that as soon as I disable a button, the postback event
doesn't fire anymore, so I'm having to manually invoke this postback in
Javascript, and this is why I need the control that initiated the
submit, as I must invoke it's postback routine.

Thanks,

wardy

Jan 19 '07 #1
4 1977
ASM
wardy a écrit :
Hi all,

Looking for a bit of help with this one...I have a situation where I
need to be able to determine the control that initiated a form's submit
action in client-side Javascript.
<form action="my.asp" blah >
<input ... >
<input type=submit name=send value="action 1">
<input ... >
<input ...>
<input type=submit name=send value="action 2">
<select ...
<input type=submit name=send value="action 3">
<input type=submit name=send value="action 4">
</form>

then on submit you asp receive witch action has been fired

send=action x

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Jan 19 '07 #2
ASM
wardy a écrit :
Hi all,

I am currently calling a Javascript
function on the client-click that returns true/false to control the
submission of a product, but I am now trying to implement functionality
to disable the buttons after the initial click, but continue with the
submit operations.
<script type="text/javascript">
var act = '';
var send = [];
function sd(what) {
act = what.value;
send[send.length] = act;
what.disabled = (act!='Submit');
}
</script>
<form action="test.htm" onsubmit="return (act =='Submit');">
..../...
<input type=submit name=send onclick="sd(this);" value="action 1">
<input type=submit name=send onclick="sd(this);" value="action 2">
<input type=submit name=send onclick="sd(this);" value="action 3">
<input type=submit name=send onclick="sd(this);" value="action 4">
<input type=submit onclick="sd(this);" value="Submit">
</form>
<a href="javascript:alert(send);">what was validated ?</a>

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Jan 19 '07 #3
ASM
ASM a écrit :

<script type="text/javascript">
var act = '';
var send = [];
function sd(what) {
act = what.value;
if(act!='Submit') {
send[send.length] = act;
what.disabled = true;
}
}
</script>

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Jan 19 '07 #4
Hi ASM,

Thanks for the reply....is there not any way to determine the
submission control without having to put the value attribute on the
controls? I was hoping for a manner that would not require any
additional coding to get this, simply due to the dynamic nature of my
application.

Thanks,

JohnW

ASM wrote:
ASM a écrit :

<script type="text/javascript">
var act = '';
var send = [];
function sd(what) {
act = what.value;
if(act!='Submit') {
send[send.length] = act;
what.disabled = true;
}
}
</script>

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Jan 23 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Gav | last post by:
Hi, At the moment i am checking that all the fields have been filled out, at the moment i am using the following... if firstname = "" and surname = "" and address1 = "" and town = "" and county...
2
by: Halldór Ísak Gylfason | last post by:
In my application I have an iframe that is empty (and not visible) initially, however when a user presses a button a form is programmatically submitted and the target is set to the IFrame. I...
7
by: Emil Frank | last post by:
Hi all, Via client side JavaScript I need to detect whether Outlook 2002 or 2003 is installed on a client machine. How can I do that using JavaScript? Thanks, Emil
5
by: guischarf | last post by:
I have the following code on files "a.php" and "b.php" ----------------------------- FILE a.php ----------------------------- <form action="a.php" method="post"> <input type="hidden"...
1
by: Roz Lee | last post by:
I have a page with two textboxes and two buttons which post back to the server. I want to detect which button has been clicked for testing purposes preferably clientside, but otherwise serverside....
3
by: =B= | last post by:
Hi all, I was wondering if anyone has had any luck with trapping the <BODY> onUnload() event in ASP.NET? The thing is, I'm writing code for an Intranet site. The code makes a call to a...
5
by: | last post by:
Hi all, Has anyone been able to write some custom javascript on the onclick event of submit button to do certain things like disable submit button, only submit form once etc. This was a breeze...
12
by: Anic297 | last post by:
Hi, This is certainly a simple question, but I'm a newbie in JavaScript. Is there a way to know if JavaScript is enabled? My php script uses JavasSript to do something. If JavaScript is not...
1
omerbutt
by: omerbutt | last post by:
HI I am WORKING ON A PROJECT IN WHICH I HAVE TO CREATE SOME INPUT FIELDS by selecting the number of inputs from a select menu the problem is that when i post the form the fields inside the div are...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.