views:

159

answers:

1

Hi,

I have a drupal form which i post using jquery when you select an option from a selectlist (a sort of quicksearch selectlist).

The porblem is that when i submit by clicking the button, it works. When I use jquery, and the button is in the form (hidden or not), it works. When I use jquery and I rmove the button, the post is done, but the "FORM_submit" function is not called and it just refreshes my page.

Can anyone explain this behaviour ?

@edit:

The strange thing is, I was thinking: because you have multiple buttons maybe you have to post the button as a parameter as well. But when I scan trough the posts, the button is not included:

Parametersapplication/x-www-form-urlencoded
form_build_id   form-138a553d76a89c82e09a231a2f55e8a9
form_id duration_search_form
keyword 103
Source
Content-Type: application/x-www-form-urlencoded Content-Length: 92 keyword=103&form_build_id=form-138a553d76a89c82e09a231a2f55e8a9&form_id=duration_search_form

Altough, this is with a jquery submit function, and a hidden button, and it works

A: 

This is because you have to post the value of the submit button also. Here comes an example how I did it in bubbletimer-6.x-2.x:

var formdata = $('#myform').serialize();
formdata += '&op=' + escape($('input[type=submit]', $('#myform')).val());
$.ajax({
  type: 'post',
  url: $('myform').attr('action'),
  data: formdata
});

Full file: http://drupalcode.org/viewvc/drupal/contributions/modules/bubbletimer/bubbletimer_ahah.js?view=markup&pathrev=DRUPAL-6--2

Yorirou
but when I do the post with a hidden button, the button is not included as a parameter
Nealv