detecting submit control in Javascript

W

wardy

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
 
A

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
 
A

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>
 
A

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>
 
W

wardy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top