element.click() on submit button not passing value

3 views
Skip to first unread message

louis w

unread,
Jul 14, 2008, 3:49:51 PM7/14/08
to Ruby on Rails: Spinoffs
I am using JS to replace my submit buttons with A tags w/ observers.
The reason for this is I want better looking buttons. When the A is
clicked it does some validation, and then "clicks" the hidden submit
button.

When JS "clicks" the button however they name/value is not getting
submitted along with the other form values in the _POST such as if a
person clicked a regular submit button. Do you know how to get this
to happen?

As an FYI, here is the code I am using:


$(form).select('INPUT[type="submit"]').each(function(b) {

new_id = 'submit_btn_'+i;

// Turning off hide so you can test the difference
// input_button = b.hide();
input_button = b;
input_button.insert({after: '<a class="button_dark submit"
id="'+new_id+'" href="#" onClick="this.blur();"><span>'+
input_button.value +'</span></a>'});
new_button = $(new_id);

// Can't use click, because sometimes mouseup/down does not happen on
the same element, there is a span in there too.
new_button.observe('mouseup', function(e) {
e.stop();
// Do some validation
if (true) input_button.click();
});

i++;

});

T.J. Crowder

unread,
Jul 15, 2008, 1:36:49 AM7/15/08
to Ruby on Rails: Spinoffs
Hi,

We've started transitioning to a new, better-named, hopefully-spam-
free group for Prototype and script.aculo.us:

http://groups.google.com/group/prototype-scriptaculous/

prototype-s...@googlegroups.com

Could you please post your question there instead? Thanks! People
might still answer here, but probably not for all that much longer...
--
T.J. Crowder
tj / crowder software / com

louis w

unread,
Jul 15, 2008, 10:14:20 AM7/15/08
to Ruby on Rails: Spinoffs
Thanks I will ask there. I was wondering what was up with all this
spam.
The name of this list makes a lot more sense too.
Reply all
Reply to author
Forward
0 new messages