submit remote form with prototype

Posted by badnaam on Stack Overflow See other posts from Stack Overflow or by badnaam
Published on 2010-06-06T07:35:21Z Indexed on 2010/06/06 7:42 UTC
Read the original article Hit count: 373

I have a remote form like this and a checkbox in it. When I select or deselect the checkbox I would like to 1 - set the value of a hidden field

2 - ajax submit this form to its designated url.

I tried $('search_form').onsubmit(), but I get an error saying onsubmit is not a function. Using prototype. Whats the best way to do this?

<form onsubmit="new Ajax.Request('/searches/search_set?stype=1', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;" method="post" id="new_search" class="new_search" action="/searches/search_set?stype=1"><div style="margin: 0pt; padding: 0pt; display: inline;"><input type="hidden" value="3TWSyMsZXI0nltz7zHAxuj1KX=" name="authenticity_token"></div>

  <a onclick="setSubmit(this);" href="#" class="submit-link-button fg-button ui-state-default fg-button-icon-left ui-corner-all" id="search_submit"><span class="ui-icon ui-icon-search"></span>'Search'</a>
  </div>   

                  <input type="checkbox" value="Energy" onclick="refreshResults(this);" name="search[conditions][article_tag][0]" id="search_conditions_article_tag_0">

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery