/    Sign up×
Community /Pin to ProfileBookmark

form submit() function in FF?

I have the following script that will be used to submit information to a search form on an existing page. The only problem is I need to have javascript automatically submit the form without extra user input. As soon as this page is loaded, it should submit itself (using the submit() in javascript).
Basically, the script works in IE but not FF.
FF javascript console reports this error: “Error: form.submit is not a function”
Does anyonve know why FF reports this or how to have the form submitted properly?
Here is the script (with real urls removed)

[code=html]<html>
<script language=”JavaScript” type=”text/JavaScript”>

document.open();
uri=’http://dfgdfgd’;
referer=’http://gdffdg’;
form=document.createElement(‘form’);
form.method=’post’;
form.action=uri;
form.action=referer;
i0=document.createElement(‘input’);
i0.type=’hidden’;
i0.name=’searchType’;
i0.value=’Basic’;
i1=document.createElement(‘input’);
i1.type=’text’;
i1.name=’firstname’;
i1.value=’someone’;
i2=document.createElement(‘input’);
i2.type=’text’;
i2.name=’lastname’;
i2.value=”;
i3=document.createElement(‘input’);
i3.type=’text’;
i3.name=’SearchTarget’;
i3.value=’Everyone’;
i4=document.createElement(‘input’);
i4.type=’submit’;
i4.name=’submit’;
i4.value=’Send Query’;
form.appendChild(i0);
form.appendChild(i1);
form.appendChild(i2);
form.appendChild(i3);
form.appendChild(i4);
b=document.createElement(‘body’);
b.appendChild(form);
h=document.getElementsByTagName(‘html’)[0];
h.appendChild(b);
form.submit();

</script>
</html>[/code]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@felgallOct 12.2005 — You can't refer to the form that way, you need to reference it by name

<form name="myform" ...> and myform.submit()
×

Success!

Help @djtaylor spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...