5

I have a very small problem,

I want to submit my code using jQuery on dropdown change:

 $("#mydropDown").change(function(){           
        $("#myForm").submit();
    });

but it is not submitting.

I also fired following code in Firebug console:

$("#myForm").submit();

it given me this output

[form#myForm]

I'm not getting what is the problem... :o?

5
  • 1
    try $("#myForm")[0].submit(); Commented Jul 25, 2012 at 5:31
  • <form enctype="multipart/form-data" id="myForm" method="post" action="mypage"> <select id="myDropDown" >Options</select> </form> Commented Jul 25, 2012 at 5:32
  • Do you have any submit event bound to this form? event handlers may prevent default submit actions if it returns false or invokes preventDefault method on event object. try to see jQuery bound event handler via $._data($('#myForm')[0]).events.submit Commented Jul 25, 2012 at 5:32
  • @jay > $("#myForm")[0].submit(); returns undefined method in console Commented Jul 25, 2012 at 5:34
  • Isn't mydropDown typo of myDropDown? Commented Jul 25, 2012 at 5:34

4 Answers 4

3

hi that time I used unbind but I really wanted to find to why it is happening. later I found answer of this question. I'm not much sure it is correct or not but it worked for me. In the same form ('#myForm') there is a submit button with id='submit' and name='submit'. I changed both to submit_btn and it worked for me hope it may help...

Thank you for your support!!!

Sign up to request clarification or add additional context in comments.

Comments

2

You may have another event bound to your form that is cancelling the submit event.

To check this, you could execute the following in the console:

console.log($('#myForm').data('events'));

Which will output all events bound to your form.

3 Comments

>>> console.log($('#myForm').data('events')); emply line showing below
@Ravi then something else is happening, check Johnny's answer for a debug method.
@Jashwant glad you like it, it's helped me out in similar situations :)
1

May be, you have another event bound, if want cleaning up:

 $("#mydropDown").change(function(){           
        $("#myForm").unbind().submit();
    });

make sure that is within

$(document).ready(function(){
  //....
})

2 Comments

srry, its "unbind()" no "remove()", srry. $("#myForm").unbind().submit();
I'm doing with this it removes form but showing when I reload also I'm getting post values.... thanks levi...
0

The jquery is pretty basic so it must be something else. To debug this I would just comment out all the jquery and see if you can get the form to submit with just a submit button.

If that doesnt work it would look at your action page.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.