Javascript form submit: Object does not support this property or method (IE7)

I am trying to submit a form using javascript. Firefox is working fine, but IE complains that the "object does not support this property or method" in the send line of this function:

function submitPGV(formName, action) { var gvString = ""; pgVisibilities.each(function(pair) { gvString += pair.key + ":" + pair.value + ","; }); $('pgv_input').value = gvString; var form = $(formName); form.action = action; form.submit(); } 

Called here:

 <a href="javascript:submitPGV('ProductGroupVisibility','config/productgroupvis/save')"> 

Here is the form:

 <form id="ProductGroupVisibility" action="save" method="post"> <input type="hidden" name="ows_gv..PGV" id="pgv_input" value=""/> </form> 

Any ideas?

+4
source share
5 answers

Try checking IE element type:

 // For getting element with id you must use # alert( typeof( $( '#ProductGroupVisibility' ))); 

Perhaps there is something else on the page with the identifier that IE selects before the form.

+5
source

What name does your <input type="submit"> ?

If you called it "submit", you redefined the form.submit() function, just like an input called "foo" would generate the form.foo property. This explains the behavior.

+14
source

beware of any form inputs using name = 'submit', they violate the javascript.submit () function!

+3
source

What javascript structure are you using? If this is jQuery, I think you need to add # to your id:

 $('#ProductGroupVisibility').submit(); 
+1
source

Are you sure your JavaScript library is loaded? (jQuery or prototype)

This worked for me in IE7 with Prototype.

Try:

 alert($('ProductGroupVisibility').id) 

See if you have a mistake.

0
source

All Articles