[Javascript] Which submit caused the event?

Tedd Sperling tedd at sperling.com
Tue Jan 1 15:50:28 CST 2013


Hassan:

Damn -- you had to make it simple didn't you!

I was hoping for something more difficult to justify my wasted couple of days tying to figure this damn thing out. :-)

In any event, many thanks for the code -- now back to my drawing board to figure out how to tie this into an ajax post (not a hint for more free code). You solved my major problem -- the rest I can do.

Cheers,

tedd




On Jan 1, 2013, at 4:22 PM, Hassan Schroeder <hassan at webtuitive.com> wrote:

> On 1/1/13 1:03 PM, Tedd Sperling wrote:
> 
>> I'm not trying to be a smart-ass, but have you tried it?
> 
> Yes, of course :-)
> 
>> 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.
> 
> <!DOCTYPE html>
> <html>
> <head>
> <script type="text/javascript">
> document.onclick=function(e){
>  var ev = window.event || e;
>  alert(ev.target.name);
> }
> </script>
> </head>
> <body>
> 
> <form action="" method="post" name="myform" onsubmit="javascript:return false;" >
>   <input type="submit" name="edit" value="Edit">
>   <input type="submit" name="save" value="Save">
>   <input type="submit" name="cancel" value="Cancel">
> </form>
> 
> </body>
> </html>
> 
> 
> -- 
> :about => about.me/hassanschroeder
> :email  => hassan at webtuitive.com
> :twitter => @hassan
> :voice  => +1 408-621-3445
> _______________________________________________
> Javascript mailing list
> Javascript at lists.evolt.org
> http://lists.evolt.org/mailman/listinfo/javascript



More information about the Javascript mailing list