[thelist] Submitting a form with javascript

Tom Dell'Aringa pixelmech at yahoo.com
Sun Nov 2 21:38:32 CST 2003


--- John Corry <lists at neoncowboy.com> wrote:
> I am at wit's end.

> And when I click the link, the mozilla javascript console tells me:
> Error: window.document.updateForm.submit is not a function
> Source File: http://nishiyama.localhost.com/admin/update_form.php#
> Line: 18
> 
> WTF!?
> Submit() is not a method of a form object?
> Window.document.updateForm is not a form object?
> 
> What is going on? I went through 10 stupid javascript tutorials and
> this is how ALL OF THEM referenced the form! 

John,

Here is your problem:

<form action="/admin/update_form.php" method="post" name="update"
id="updateForm">

the NAME of your form is "update" NOT updateForm. You do NOT
reference the ID, but the NAME attribute.

Do this:

document.forms['update'].submit();

You don't need the window reference. Also, make use of the DOM level
0 forms array, its good form. As for your HREF, it is not accessible.
Read .jeffs "Forms and JavaScript living in Harmony" (paraphrasing
title) to learn how to use an HREF correctly with JS. Its in the
articles section of evolt.org

HTH

Tom


=====
http://www.pixelmech.com/ :: Web Development Services
http://www.DMXzone.com/ :: JavaScript Author / Every Friday!
http://www.thywordistruth.net/ :: Eternal Life

"I'll ho ho and ha ha you!" (Daffy Duck)


More information about the thelist mailing list