Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

auto submit a form, but there is a input[name="submit"] field...

133 views
Skip to first unread message

WenDong Zhang

unread,
Jul 9, 2009, 8:35:52 AM7/9/09
to dev-...@lists.mozilla.org
Hi guys:

I've met a weird use case. there is a form, and I want to auto submit when
the page loaded completed.
we can do it by FORM.SUBMIT()! but, here I get a headache, there is a input
field whose name is 'submit'...
so when I use form.submit(), there is a error : form.submit() is not a
function (of course form.submit is the input node...)

<form id="form1" action="/">
<input type="text" name="submit" />
</form>
<script type="text/javascript">
var f = document.getElementById('form1');
//console.log(f);
//console.log(f.submit);
f.submit();
</script>


so, I want to know is there another way to make the form auto submit

--
Best Regards!
Wen Dong

Martin Honnen

unread,
Jul 9, 2009, 9:25:09 AM7/9/09
to

You will need to rename that input first.

--

Martin Honnen
http://msmvps.com/blogs/martin_honnen/

WenDong Zhang

unread,
Jul 9, 2009, 10:20:46 PM7/9/09
to Martin...@gmx.de, dev-...@lists.mozilla.org
yes, I did this.

form.action += (form.action.indexOf('?') == -1 ? '?' : '&') + 'submit=' +
form.submit.value;
form.submit.name = '__'; // rename
form.submit();

this works now, but the submit value is sent by GET method, if the backend
changes (such as php will receive the request value by $_POST, $_GET,
$_REQUEST), it may not get the submit's value.

> _______________________________________________
> dev-ajax mailing list
> dev-...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-ajax

0 new messages