Tuesday, 15 February 2011

javascript - Cannot programmatically submit form -



javascript - Cannot programmatically submit form -

this question has reply here:

“submit not function” error in javascript 6 answers

cannot form submit programmatically, despite trying several ways. tried pure js, tried jquery. no success.

i have form tag :

<form action="https://docs.google.com/forms/d/13zex8zsesnzz3a8ub4ju4odb5wzfaqqq2pq2cglie6m/formresponse" method="post" id="ss-form" target="_self" onsubmit="" name="eform"> <!--my form stuff--> <input type="submit" name="submit" value="submit" id="ss-submit"> </form>

here i've tried :

/*jquery*/ $('#ss-form').submit(); /*javascript*/ document.getelementbyid('ss-form').submit(); document.eform.submit();

none of them work. not sure why, assuming has me trying submit google form. if physically click submit works fine.

any , help apprecaiated.

the problem have field (htmlinputelement) name submit in form. that's why document.getelementbyid('ss-form').submit not function object.

so, next error:

typeerror: object not function

the solution remove element. should careful verify if browser thinks it's element , not function:

if (typeof document.getelementbyid('ss-form').submit === "object") { document.getelementbyid('ss-form').submit.remove(); } document.getelementbyid('ss-form').submit();

javascript jquery forms google-form

No comments:

Post a Comment