Hi fREW,

I'm not sure I have well understand your problem, but remember that
when you apply an event, the context (value of this is the element
originating the event, so if you want for exemple disabled every
button but not the one clicked, just do something like that:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/...">
<html xmlns="http://www.w3.org/1999/xhtml";>
    <head>
        <script src="prototype.js" type="text/javascript"></script>
    </head>
    <body>
        <input id="bt1" type="submit"></input>
        <input id="bt2" type="submit"></input>
        <script type="text/javascript">
function greySubmits() {
alert(this.id);                         //==> the context is the
clicked button !!
  $$("input[type='submit']").without(this).each(function(e){e.disable
()})    //==> disable all button without the one clicked !!

}

  Event.observe(window, 'load', function() {
      $$("input[type='submit']").each(function(e) {
          Event.observe(e, 'click', greySubmits);
      });
    });         </script>
    </body>
</html>

--
david

On 17 fév, 05:14, fREW Schmidt <fri...@gmail.com> wrote:
> > Hello Javascript friends!
>
> > I am working on a fairly simple javascript issue and I can't seem to figure
> > out what is going wrong.  I have tried two setups, both of which don't
> > work.  The simpler is this:
>
> > In our html we have a form and in the form tag we add an
> > onsubmit="greySubmits()" attribute.  This is the greySubmits function.
>
> > function greySubmits() {
> >   $$("input[type='submit']").each(function(e){e.disable()})
> > }
>
> > I also tried to add this to our javascript and remove the onsubmit tag from
> > our html:
>
> >   Event.observe(window, 'load', function() {
> >       $$("input[type='submit']").each(function(e) {
> >           Event.observe(e, 'click', greySubmits);
> >       });
> >     });
>
> > The problem is that one way or the other, when we do this for some reason
> > the javascript does not set along the value of the button that was clicked.
> > This means that the preview button no longer works as we check the value of
> > the submit button field for that.  Any idea what we are doing wrong here?
>
> > Thanks!
>
> I ended up doing this.  Let me know if there is a better way:
>
> function greySubmits(e) {
>   // First replace the button so that the correct commit will get sent
>   var value = e.currentTarget.defaultValue;
>   $(e.currentTarget).insert('<input type="hidden" name="commit" value="' +
> value +'" />');
>
>   // Then disable buttons so people can't double post
>   $$("input[type='submit']").each(function(e){e.disabled = true;})
>
> }
>
> Event.observe(window, 'load', function() {
>     $$("input[type='submit']").each(function(e) {
>         Event.observe(e, 'click', greySubmits);
>       });
>   });
>
> --
> fREW Schmidthttp://blog.afoolishmanifesto.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to