3 Replies - 1219 Views - Last Post: 25 April 2003 - 10:08 AM

#1 klewlis  Icon User is offline

  • cur tu me vexas?

Reputation: 8
  • View blog
  • Posts: 1,723
  • Joined: 09-November 01

Javascript Error

Posted 25 April 2003 - 09:51 AM

ok, in my head i have this simple function:

function subscribeForm()
{
	var email = "subscribe.php?email=" + this.forms[0].email.value;
	window.open(email,'subscribe','width=200,height=200');
}



which is called when a user submits a form, like this:
<form name="subscribe" action="" target="" onsubmit="subscribeForm();">



and i'm getting an error saying that forms.0 is null or not an object. what's the deal?

Is This A Good Question/Topic? 0
  • +

Replies To: Javascript Error

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Javascript Error

Posted 25 April 2003 - 10:02 AM

forms[0] is often used when the form has no name. Because your form has a name, it may be looking for that. Maybe you could try

var email = "subscribe.php?email=" + this.subscribe.email.value;


Might be the problem. Not quite sure.
Also, you might want to try document.subscribe.email.value

This post has been edited by Amadeus: 25 April 2003 - 10:04 AM

Was This Post Helpful? 0
  • +
  • -

#3 klewlis  Icon User is offline

  • cur tu me vexas?

Reputation: 8
  • View blog
  • Posts: 1,723
  • Joined: 09-November 01

Re: Javascript Error

Posted 25 April 2003 - 10:06 AM

i tried using the name originally and got the same error.

document.forms works. thanks :)
Was This Post Helpful? 0
  • +
  • -

#4 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Javascript Error

Posted 25 April 2003 - 10:08 AM

np! Glad it worked.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1