Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML JavaScript

null or not an object error

Javascript coding ..

Moderators: macek, egami, gesf

null or not an object error

Postby popeye » Sat Apr 16, 2005 8:17 am

Can someone identify the mistake in the following simple code or suggest a better way to reload a form?

Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<script language="JavaScript">
function reloadform() {
document.form.outx.submit();
}
</script>
</head>
<body>
<form name='outx' action='index.php'>
<select name='sel1' onchange="javascript: reloadform()">
<option>A</option><option>B</option><option selected>C</option>
</select>
<select name='sel2'>
<option>1</option><option selected>2</option><option>3</option>
</select>
Submit:<input type='submit' value='Submit me'>
</form>
</body>
</html>


I keep getting the following error:

"document.form.outx is null or not an object."

when trying to change the selection from the first option list.
Thanks.
User avatar
popeye
New php-forum User
New php-forum User
 
Posts: 120
Joined: Sat Jan 03, 2004 7:06 pm
Location: New York, NY

Postby sadisticmachine » Sat Apr 16, 2005 8:43 am

I think its just document.outx, not document.form.outx
sadisticmachine
New php-forum User
New php-forum User
 
Posts: 109
Joined: Tue Nov 02, 2004 5:33 am

Postby popeye » Sat Apr 16, 2005 9:26 am

Yes. You are right. It works fine now. Thanks
Would you know what has to be changed if I need to load a different page than the default action value of the form?
User avatar
popeye
New php-forum User
New php-forum User
 
Posts: 120
Joined: Sat Jan 03, 2004 7:06 pm
Location: New York, NY

Postby sadisticmachine » Sat Apr 16, 2005 9:36 am

somewhere you would have to put:

Code: Select all
document.outx.action = "someaction.php"


to set the action to someaction.php
sadisticmachine
New php-forum User
New php-forum User
 
Posts: 109
Joined: Tue Nov 02, 2004 5:33 am

Postby ruturajv » Sun Apr 17, 2005 7:47 pm

you can either use
Code: Select all
document.forms['outx']
object to access that form's properties
User avatar
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India


Return to JavaScript

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.