yawnmoth wrote on 18 apr 2007 in comp.lang.javascript
:
Quote:
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)