Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

document.forms['myformname'].submit() bombs 1

Status
Not open for further replies.

HelloMike

MIS
Feb 14, 2003
210
GB
I have a magazine subscription. I go into the publisher's website to change my address details (coz I've just moved house), and get to a list of hyperlinks. I click on one of these and a javascript error pops up:
Code:
    Object doesn't support this property or method.
So I View Source and locate the offending bit of code:
Code:
    <a href=&quot;javascript:document.forms['myformname'].submit();&quot;>Some text</a>
Before I phone or email the publisher to rant at them for pointing me at a useless non-facility I'd like to be able to provide them with some sort of solution, because it seems to me it should be a simple thing to sort out. But my javascript is fairly lamentable, hence this post.

Any solutions ?

Oh, er, I'm using IE6 SP1.

Cheers,
Mike
 
try document.forms[red]([/red]'myformname'[red])[/red].submit();&quot;>

-pete
 
if it is the first form on the page:
[tt]document.forms[0].submit();[/tt]
or call it by name:
[tt]document.myformname.submit();[/tt]
or refer to it using DOM:
[tt]document.getElementByName('myformname').submit();[/tt]
:)

One thing to watch out for, if they have a submit button there with name=&quot;submit&quot; javascript gets confused between the form's submit method and the submit button :(

Posting code? Wrap it with code tags: [ignore]
Code:
[/ignore][code]CodeHere
[ignore][/code][/ignore].
 
Thanks clarkin,

You've prompted me to look at some stuff I wrote ages ago, and one construct that works fine is
Code:
document.myformname.submit();

Cheers,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top