472,980 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,980 software developers and data experts.

submit is not a function in FF but is in IE

I'm trying to write a so-called bookmarklet for a specific web app and
am having some difficulty. One of the names of a specific forms
inputs is submit. As such, doing
document.getElementById('whatever').submit() doesn't work in FireFox
(it works in IE) because submit is now referring to the input field -
not to the function.

The usual "change the input's name" doesn't work because I don't have
any control over the site / web app. That's why I'm trying to write
the bookmarklet in the first place.

I've observed that document.getElementById('whatever').submit.click()
works in FireFox, but it doesn't work in IE. Now, I can do if
(document.getElementById('whatever').submit)) to decide which one I
want to do, but I'm wondering if there's a better way.

For example, maybe there's a way to get the input by the name? eg. a
getInputByName() function? Or maybe there's a way to execute the
submit() function without actually calling
getElementById('whatever').submit()?

Apr 18 '07 #1
6 11314
yawnmoth wrote on 18 apr 2007 in comp.lang.javascript:
I'm trying to write a so-called bookmarklet for a specific web app and
am having some difficulty. One of the names of a specific forms
inputs is submit. As such, doing
document.getElementById('whatever').submit() doesn't work in FireFox
(it works in IE) because submit is now referring to the input field -
not to the function.

The usual "change the input's name" doesn't work because I don't have
any control over the site / web app. That's why I'm trying to write
the bookmarklet in the first place.

I've observed that document.getElementById('whatever').submit.click()
works in FireFox, but it doesn't work in IE. Now, I can do if
(document.getElementById('whatever').submit)) to decide which one I
want to do, but I'm wondering if there's a better way.

For example, maybe there's a way to get the input by the name? eg. a
getInputByName() function? Or maybe there's a way to execute the
submit() function without actually calling
getElementById('whatever').submit()?
This does not "work" in IE or FF:

===========================================
<form>
<input name='submit' value=3>
</form>

<button onclick='document.forms[0].submit();'>
submit
</button>
===========================================

this does:

===========================================
<script type='text/javascript'>
function doit(x){
document.forms[0].innerHTML+='<input type=submit id=qqq>'
// or use the DOM version of above.
// if you use name=qqq it will be send in the querystring.
document.forms[0].elements['qqq'].click()
}
</script>

<body>
<form>
<input name='submit' value=3>
</form>

<button onclick='doit(this);'>
submit
</button>
===========================================

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 18 '07 #2
yawnmoth wrote:
I'm trying to write a so-called bookmarklet for a specific web app and
am having some difficulty. One of the names of a specific forms
inputs is submit. As such, doing
document.getElementById('whatever').submit() doesn't work in FireFox
(it works in IE) because submit is now referring to the input field -
not to the function.
Well, naming your submit button "submit" sometimes bites you in the arse.
Mick
>
The usual "change the input's name" doesn't work because I don't have
any control over the site / web app. That's why I'm trying to write
the bookmarklet in the first place.

I've observed that document.getElementById('whatever').submit.click()
works in FireFox, but it doesn't work in IE. Now, I can do if
(document.getElementById('whatever').submit)) to decide which one I
want to do, but I'm wondering if there's a better way.

For example, maybe there's a way to get the input by the name? eg. a
getInputByName() function? Or maybe there's a way to execute the
submit() function without actually calling
getElementById('whatever').submit()?
Apr 18 '07 #3
On 18 Apr, 05:43, yawnmoth <terra1...@yahoo.comwrote:
document.getElementById('whatever').submit() doesn't work in FireFox
(it works in IE) because submit is now referring to the input field -
not to the function.
An input element does not have a submit() method, so I'd be surprised
if what you are suggesting works in any browser. I think you must
actually mean to be calling the submit() method on the form element.
For example:

function submitForm() {
document.getElementById("myForm").submit();
}

<form id="myForm" action="blah" method="post">
<input type="text" name="blahblah">
</form>
<button type="button" onclick="submitForm">Submit Form</button>

The above should work.

Apr 18 '07 #4
wisestpotato said the following on 4/18/2007 9:35 AM:
On 18 Apr, 05:43, yawnmoth <terra1...@yahoo.comwrote:
>document.getElementById('whatever').submit() doesn't work in FireFox
(it works in IE) because submit is now referring to the input field -
not to the function.

An input element does not have a submit() method, so I'd be surprised
if what you are suggesting works in any browser.
Then you should test it.
I think you must actually mean to be calling the submit() method on the form element.
Yes, that is what he wants. But, he can't change the name in the HTML
itself. The solution is simple though.
For example:

function submitForm() {
document.getElementById("myForm").submit();
}

<form id="myForm" action="blah" method="post">
<input type="text" name="blahblah">
</form>
<button type="button" onclick="submitForm">Submit Form</button>

The above should work.
Did you test that? onclick="submitForm()" might work better.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 18 '07 #5
yawnmoth said the following on 4/18/2007 12:43 AM:
I'm trying to write a so-called bookmarklet for a specific web app and
am having some difficulty. One of the names of a specific forms
inputs is submit. As such, doing
document.getElementById('whatever').submit() doesn't work in FireFox
(it works in IE) because submit is now referring to the input field -
not to the function.

The usual "change the input's name" doesn't work because I don't have
any control over the site / web app. That's why I'm trying to write
the bookmarklet in the first place.
Change it programatically by changing the .name property of the input.

document.getElementById('submit').name="newName"
document.getElementById('theFormID').submit()

No telling which name will get submitted to the server though for the input.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 18 '07 #6
On 18 Apr, 18:37, Randy Webb <HikksNotAtH...@aol.comwrote:
>
An input element does not have a submit() method, so I'd be surprised
if what you are suggesting works in any browser.

Then you should test it.
Should I? Is it worth my time to track down copies of all the
available web browsers and test it? Can I not just reasonably
speculate that I would be surprised if it worked?
>
Did you test that? onclick="submitForm()" might work better.
Beg your pardon, slip of the finger.

wp.

Apr 19 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: DB | last post by:
Hi All Having stared at this all morning and altered various things with no effect other then to exasperate the problem i'm wondering if anyone could take a look at the code below and see why on...
29
by: Mic | last post by:
Goal: delay execution of form submit Code (Javascript + JScript ASP): <% Response.Write("<OBJECT ID='IntraLaunch' STYLE='display : none' WIDTH=0 HEIGHT=0...
2
by: Margaret Werdermann | last post by:
Hi all: I'm having a nasty time with a particularly difficult piece of code and was hoping someone might be able to help me. I have a FormMail form that originally worked perfectly. Then, I...
8
by: horos | last post by:
hey all, Ok, a related question to my previous one on data dumpers for postscript. In the process of putting a form together, I'm using a lot of placeholder variables that I really don't care...
2
by: Mel | last post by:
i want to diable all submit_buttons untill all my form elements are populated. how can i do that ? thanks
4
by: gimme_this_gimme_that | last post by:
Hi, This is sort of a : How to build a Yes/No dialog box qquestion. Or perhaps a question about getting javascript variables from a pop-up window and processing them on a submit. This is...
5
by: Navillus | last post by:
Hey gang, I have a login form that is empty by default, but can be filled with values from a previous form: <input type=text maxlength="40" size="40" name="user" value="`usr`"> <input...
10
by: ljlolel | last post by:
So.. I have a form that submits to an ASP.net site made in C-sharp. The ASP site is not mine, i do not have the server side code. When I submit from my form by pressing the Submit button, I get...
1
by: gbezas | last post by:
Hi All, I have added an event handler to redirect form.submit() to a newSubmit() method that I have defined (which does some additional processing before submitting the form). Additionally I...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.