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

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 
For more options, visit this group at 

Reply via email to