[Javascript] Which submit caused the event?
Tedd Sperling
tedd at sperling.com
Tue Jan 1 15:03:02 CST 2013
On Jan 1, 2013, at 11:55 AM, Hassan Schroeder <hassan at webtuitive.com> wrote:
> On 1/1/13 8:04 AM, Tedd Sperling wrote:
>
>> Let's say I have a form containing three input statement, like so:
>>
>> <form action="" method="post" name="myform" onsubmit="javascript:test(); return false;" >
>> < input type="submit" name="edit" value="Edit">
>> < input type="submit" name="save" value="Save">
>> < input type="submit" name="cancel" value="Cancel">
>> </form>
>>
>> If this form is submitted, how can I tell what the user clicked via JavaScript?
>
> event.target or event.srcElement (IE-specific)
I'm not trying to be a smart-ass, but have you tried it?
Here's how you can prove your assertion -- write a script that simply shows which input submit (as shown above) was clicked via an alert. It should be simple enough, but I've spent a couple of days trying to do it and believe me I've tried event.target as well as a couple hundred other combinations of ambiguous javascript terms INCLUDING jQuery's answer to all of this, which doesn't work for me either.
I did get something to work, see here:
http://php1.net/jQuery/test.php
Everything is there.
However, when I try to take the result of this to an ajax POST, I find it only works once -- I'm giving up for today.
Cheers and thanks for your time.
tedd
_____________________
tedd at sperling.com
http://sperling.com
More information about the Javascript
mailing list