Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

JavaScript err 'is null or not an object"

Posted on 2009-02-18
5
Medium Priority
?
972 Views
Last Modified: 2012-06-21
I'm trying to validate a form to verify that the user selects at least one checkbox.  I have seen several examples on the web, and I thought mine should mimic those pages, but instead I continually receive error  'document.rtaform.region.0' is null or not an object' every time I try.  This is part of the code.  Please point me in the right direction.  Thanks!
<script>
function checkBoxes()
{
	if (document.rtaform.region[0].checked == false)
	{
	if (document.rtaform.region[1].checked == false)
	{
	if (document.rtaform.region[2].checked == false)
	{
	alert('Please Select a Region');
	return false;
}
}
	return true;
}
 
function verifyChecked()
{
	if (!checkBoxes()) return false;
	document.rta.submit();
	return true;
}
 
</SCRIPT>
 
<form name ="rtaform" action="rtatickets.cfm?bdate=#bdate#&btime=#btime#&edate=#edate#&etime=#etime#&ticketstatus=#ticketstatus#" method = "get">
 
	<div class="ricGroupbox" ric:title="Entry Date and Time Info" ric:width = 600>
		<table width="600" height="82"><br>
	  <STRONG>Be sure to use DD-MON-YY format for Dates and HH:MM:SS format for Times</STRONG> <br>
	  <br>
		<tr>
			<td width="150"><label class="ricRequired">Begin Date: </label></td>
		  	<td width="125"><input type="text" size=15 name= "bdate" <cfoutput> value=#todaysdate# </cfoutput> onBlur="bdate.toUppercase" class="ricDefaultText"/></td>
			  <td width="200"><label class="ricRequired">Time (Optional):</label></td>
			  <td width="200"><input type="text" name= "btime" size=15 value="00:00:00" class="ricDefaultText"/></td>
			</tr>
			<tr>
	     	  <td width="105"><label class="ricRequired">End Date: </label></td>
		     <td width="154"><input type="text" size=15 name= "edate" <cfoutput> value=#todaysdate# </cfoutput> onBlur="edate.toUppercase" class="ricDefaultText"/></td>
			 <td width="200"><label class="ricRequired">Time (Optional):</label></td>
			 <td width="200"><input type="text" name= "etime" size=15 value="23:59:59" class="ricDefaultText"/></td>
		</tr>
	  </table>
	</div>  <!-- Date and Time Section END -->
 
	<div class="ricGroupbox" ric:title="Region Selection" ric:width = 600>
		<table width="700" height="20">
			<tr>
			<td width="125"><label>Northern</label></td>
			<td width="150"><input type="checkbox" name= "region" value = "Northern" checked class="ricDefaultText"/></td>
			</tr>
			<tr>
			<td width="125"><label>Southern</label></td>
			<td width="150"><input type="checkbox" name= "region" value = "Southern" checked class="ricDefaultText"/></td>
			</tr>
			<tr>
			<td width="200"><label>Western</label></td>
			<td width="150"><input type="checkbox" name= "region" value = "Western" checked class="ricDefaultText"/></td>
			</tr>
	  </table>
	</div>  <!-- Region Selection END -->
 
 
	  <br><br>
 
      <input type="submit" value="Run Report" onClick="verifyChecked()">

Open in new window

0
Comment
Question by:UPRRDevelopers
  • 3
5 Comments
 

Author Comment

by:UPRRDevelopers
ID: 23675439
Well I noticed that I have three opening IF brackets in the checkBoxes function but only two to close.  I added a third closing bracket, but that didn't fix the problem.
0
 
LVL 13

Accepted Solution

by:
srikanthmadishetti earned 2000 total points
ID: 23675722
first thing
 
pleasechnage your submit to this
<input type="submit" value="Run Report" onClick=" return verifyChecked()">
add return
 
and then js function checkboxes change to this.
function checkBoxes()
{
 if (document.rtaform.region[0].checked == false)
 {
 if (document.rtaform.region[1].checked == false)
 {
 if (document.rtaform.region[2].checked == false)
 {
 alert('Please Select a Region');
 return false;
}
}
}
 return true;
}
 
0
 

Author Comment

by:UPRRDevelopers
ID: 23675793
Thanks... I made the changes, but I still get the error.  This is it exactly:

Line: 18 (which is the first line of the checkBoxes function after the bracket)
Char: 1
Error:  'document.rtaform.region.0' is null or not an object
Code:0
0
 

Author Closing Comment

by:UPRRDevelopers
ID: 31548473
I found it ... I never closed the /FORM tag.  When I did that, everything worked fine.  Thanks for the help.
0
 
LVL 1

Expert Comment

by:boodyguard
ID: 24369157
I think that this error is return because the tickbox is not checked ... then the javascript test something who don't exist.
Try to replace by :
if (document.rtaform.region[0] != null)

It will test if it exist, the tickbox is not send in the form if not "ticked"
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Integration Management Part 2
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question