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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object required Error 2

Status
Not open for further replies.
Oct 11, 2006
300
US
I have a Javascript function that toggles the visibility of 2 different divs:

Code:
function showHide(el)
{
	var f = el.form;
	for(var i=0; i<f.crystalradio.length; i++)
	{
		if( f.crystalradio[i].checked )
		{
			switch( f.crystalradio[i].value )
			{
				case 'CommissionStatement':
				case 'PaymentReconciliation':
					document.getElementById( 'commpay' ).style.display = 'block';
					document.getElementById( 'salesrank' ).style.display = 'none';
					//document.getElementById( 'quarter_perf_team' ).style.display = 'none';
					//document.getElementById( 'quarter_Perf' ).style.display = 'none';
					//document.getElementById( 'sales_prod' ).style.display = 'none';
				break;
				case 'SalesRanking':
					document.getElementById( 'commpay' ).style.display = 'none';
					document.getElementById( 'salesrank' ).style.display = 'block';
					//document.getElementById( 'quarter_perf_team' ).style.display = 'none';
					//document.getElementById( 'quarter_Perf' ).style.display = 'none';
					//document.getElementById( 'sales_prod' ).style.display = 'none';
				break;
			}
		}
	}
}

My error is at line no 14 which is:

Code:
switch( f.crystalradio[i].value )

I have a form element within the script:

Code:
<form="Reports" Method="Post">

And my div tags are like this:

[code<div id="commpay" name="commpay" style="display:none;">
Commission arrives here
</div>
<div id="salesrank" name="salesrank" style="display:none;">
Sales arrives here
</div>
[/code]

Any ideas why I am getting the error?

Thanks.


 
Any ideas why I am getting the error?

I think that this probably has a lot to do with it:

Code:
<form="Reports" Method="Post">

-should be-

<form id="Reports" method="post">

As such, your form is not properly declared because there is no such thing as a form="reports" tag. All HTML forms are declared by a < symbol, the tag name, a space, and then all attributes. You have no space between the word form and the equals sign so the parser didn't recognize it and as such did not acknowledge the existance of a form. So, on that line of your code that you got an error, you were referencing a form that didn't exist.

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
ReportingAnalyst, did that fix your problem?

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
I still get the Object Expected error.

My Javascript is:

Code:
function s_Hide(el){
	obj = document.getElementById(el).style;
	(obj.display == 'none')? obj.display = 'block' : obj.display = 'none';
}

My link within the < a href> tag is:

Code:
<a href="#" class="a_style" onclick="s_Hide('<%=aSubordinates(c_Subordinate, iRowLoop)%>'); return false;"><%=aSubordinates(c_EmpName,iRowLoop)%></a><font size=1>&nbsp;(<%=aSubordinates(c_EmpID,iRowLoop)%>)</font><br>

My form is:

Code:
<form id="commission" name="commission" method="post" action="ViewReports4.asp" onSubmit="return ValidateData(this);">

What is weird is that in the Java Console, I get an error:

Object Expected
Line 230

But at line 230, I have no HTML code nor any Javascript code.

I have this line at line 230.

Code:
'Changed this from managerid to subordinate id because we want to see the subordinates for the member_subordinate

Which is a VBScript comment.

Any ideas?

Thanks.
 
Show us the HTML output, not the ASP script. Or check the line number of the View->Source, since that's what the browser is working with, not the ASP scripting.

Lee
 
The lines aren't matching up because you're checking line 230 of your asp file. The client has no idea what line in your source file the error is because it never sees that source code. The source code runs on the server and then sends the html/javascript to the browser depending on what the server-side source decides to send.

So, the error message is saying that the error is happening on line 230 of the HTML sent to the browser. To find out exactly what's happening all you'll have to do is a view-source of your code and look at line 230 of THAT code, not the asp source.

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
My HTML Code is:

Code:
<HTML>
<HEAD>
<LINK href="CSS_Source.css" type=text/css rel=stylesheet>
<Script Language="text/javaScript">


var isOrderDetailSelected = false;
var isNonOrderDetailSelected = false;
var isReportingPeriodSelected = false;

/*************************************************************
This Function validates that the users select the required
parameters to view the crystal reports
**************************************************************/

function ValidateData(f) {

	//Check to make sure a report is selected.
		// validate myradiobuttons
		myOption = -1;
		for (i=f.crystalradio.length-1; i > -1; i--) {
			if (f.crystalradio[i].checked) {
				myOption = i;

				if (f.crystalradio[i].value == 'CommissionStatement') {
					//alert('crystalradiovalue ' + i + ' ' + f.crystalradio[i].value);
					if (f.period_Comm_Pay.value == 'Select') {
						alert("Select a Reporting Period");
						return false;
					}
				}

				if (f.crystalradio[i].value == 'PaymentReconciliation') {
					//alert('crystalradiovalue ' + i + ' ' + f.crystalradio[i].value);
					if (f.period_Comm_Pay.value == 'Select') {
						alert("Select a Reporting Period");
						return false;
					}
				}

				if (f.crystalradio[i].value == 'QuarterlyPerformance-Team') {
					//alert('crystalradiovalue ' + i + ' ' + f.crystalradio[i].value);
					if (f.period_QPT.value == 'Select') {
						alert("Select a Reporting Period");
						return false;
					}
					if (f.Family.value =='SelectFamily') {
						alert("Select a Family");
						return false;
					}
				}

				if (f.crystalradio[i].value == 'SalesRanking') {
					//alert('crystalradiovalue ' + i + ' ' + f.crystalradio[i].value);
					if (f.period_SR.value == 'Select') {
						alert("Select a Reporting Period");
						return false;
					}
					if (f.ReportType_SR.value =='SelectReport') {
						alert("Select a Report");
						return false;
					}
					if (f.Region_SR.value =='SelectRegion') {
						alert("Select a Region");
						return false;
					}
				}
				if (f.crystalradio[i].value == 'QuarterlyPerformanceReport') {
					//alert('crystalradiovalue ' + i + ' ' + f.crystalradio[i].value);
					if (f.period_QP.value == 'Select') {
						alert("Select a Reporting Period");
						return false;
					}
					if (f.Region_QP.value =='SelectRegion') {
						alert("Select a Region");
						return false;
					}
					if (f.Family_QP.value =='SelectFamily') {
						alert("Select a Family");
						return false;
					}
				}
				if (f.crystalradio[i].value == 'SalesProductivity') {
					//alert('crystalradiovalue ' + i + ' ' + f.crystalradio[i].value);
					if (f.period_SP.value == 'Select') {
						alert("Select a Reporting Period");
						return false;
					}
					if (f.Currency_SP.value =='Currency') {
						alert("Select a Currency");
						return false;
					}
					if (f.Report_SP.value =='SelectReport') {
						alert("Select a Report");
						return false;
					}
					if (f.Region_SP.value =='SelectRegion') {
						alert("Select a Region");
						return false;
					}
				}
				if (f.crystalradio[i].value == 'OrderDetailYTD') {
					//alert('crystalradiovalue ' + i + ' ' + f.crystalradio[i].value);
					if (f.StartDate.value == 'SelectStart') {
						alert("Select a Start Date");
						return false;
					}
					if (f.EndDate.value =='SelectEnd') {
						alert("Select an End Date");
						return false;
					}
				}

			}
		}
		if (myOption == -1) {
			alert("You must select a report to view");
			return false;
		}
		return true;
}

/*****************************************************
This function shows and hides the org structure tree
******************************************************/
function s_Hide(el){
	obj = document.getElementById(el).style;
	(obj.display == 'none')? obj.display = 'block' : obj.display = 'none';
}

/*******************************************************
This function ensures that the users select a start date which is less than end date
********************************************************/

function ParseDate(dateString)
{
	//Date is in the format of mm/dd/yyyy pulled from a dropdown box.
   var dateSep = "/";
   //firstSep = dateString.indexOf(dateSep);
   //lastSep = dateString.lastIndexOf(dateSep);
   date = dateString.split(dateSep, 3);
   //alert(date[0] + ", " + date[1] + ", " + date[2]);
   var date = new Date(date[2], date[0]-1, date[1]);
   //alert(date); //parsing is working fine. returns the date object.
   return date;
}

function ValidateDate(startDateStr, endDateStr)
{
   startDate = ParseDate(startDateStr);
   endDate = ParseDate(endDateStr);

   //alert(startDate.toString()); //here is the error - when it convert to a string it is returning funny values.
   //alert(startDate.getDate());
   if (endDate < startDate) {
     alert("Start Date should be less than End Date");
   }
   //else
   //  alert("Bad");
}

</script>

</HEAD>
<TITLE>View Commissions Reports</TITLE>


<BODY>

<center><html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title></title>
<style type="text/css">
label
{
width: 5em;
float: left;
text-align: right;
margin-right: 0.5em
display: block
}
</style>
</head>

<body>
<table align=center width=100%>
	<tr>
		<td width=30%><img src="image004.jpg"></img></td>
		<td width=40%><b><font face="arial" size=5 color="0033AB">SALES COMPENSATION</font><b></td>
		<td align=right width=30%><b><font face="arial" size=2 color="0033AB">
		Today's Date: 11/13/2006<BR>Last Updated Date: 11/10/2006
		</font><b>
		</td>
	</tr>

</table>

</body>

</html></center>

<form name="commission" id="commission" method="post" action="ViewReports4.asp" onSubmit="return ValidateData(this);">

<table width="100%">
  <tr>
    <td class="logon">

	Employee:Mgr1(41495)
    </td>
  </tr>
</table>


<!-------------------------------------------------------------------------------
Display the Org Tree
--------------------------------------------------------------------------------->
<div class="container1">
   <div class="caption">Organization</div>
	<br><br>

		<input type="radio" checked name="empid" id="empid" value="41495">
		<a href="#" class="a_style" onclick="s_Hide('862336'); return false;">Mgr1</a href><font size=1>(41495)</font><br>
		<span id="862336" style="display: none">
		&nbsp;&nbsp;
							<input type="radio" name="empid" id="empid" value="41475">
							Sub1&nbsp;<font size=1>(41475)</font>
							<br>
							&nbsp;&nbsp;
							<input type="radio" name="empid" id="empid" value="41612">
							Sub2&nbsp;<font size=1>(41612)</font>
							<br>
							&nbsp;&nbsp;
							<input type="radio" name="empid" id="empid" value="41503">
							Sub3&nbsp;<font size=1>(41503)</font>
							<br>
							&nbsp;&nbsp;
							<input type="radio" name="empid" id="empid" value="41502">
							Sub4&nbsp;<font size=1>(41502)</font>
							<br>
							&nbsp;&nbsp;
							<input type="radio" name="empid" id="empid" value="41558">
							Sub5&nbsp;<font size=1>(41558)</font>
							<br>

						</span>

		</span>

</div>
<!----------------------------------------------------------------------------------------
'Reports Display Begins
'--------------------------------------------------------------------------------------->

<div class="container2">
	<div class="caption">Reports</div>
	<br><br>
	<font class="body_text">Select Plan (Monthly Reports)</font>
	<br>
	<!--Include Virtual="/scripts/Padmaja/Testing1/Reports_Display.asp"-->
</div>
<!-----------------------------------------------------------------------------------------
'Reports Display Ends
'------------------------------------------------------------------------------------------>
<div class="container3">
	<div class="top_hire">
	<font class="body_caption">President's Club</font>
	<br>
	<html>

<head>
<title>XML Data in TextArea</title>
</head>

<body>


<textarea readonly="readonly" rows=5 cols=30>


</textarea>


</body>
</html>
	</div>
	<div class="top_hire">
	<font class="body_caption">New Hires</font>
	<html>
<head></head>
<title>Reports</title>
<body>
<br>


<textarea rows=5 cols=30 readonly>
Hongsuraphan, Monchai

</textarea>
</body>
</html>
	</div>
	<div class="top_hire">
	<font class="body_caption">Other Information</font>
	<br><br>
	<html>
<head>
<LINK href="CSS_Source.css" type=text/css rel=stylesheet >
</head>
<title></title>
<body>
Please review your statements thoroughly and notify Commissions of any discrepancies.

</body>
</html>
	</div>
</div>

</form>
</body>
</html>

My line where it errs is:

Code:
<a href="#" class="a_style" onclick="s_Hide('862336'); return false;">Mgr1</a href><font size=1>(41495)</font><br>

 
You really need to validate your code. There are MULTIPLE errors that are causing you problems and will cause problems in the future. You have multiple <body>, <head>, and <title> tags, to begin with.

Basically, the following has errors that prevent any of your Javascript from working. I'll leave it to you to fix the errors.
Code:
<Script Language="text/javaScript">

Lee
 
Yeah, I fixed the error.

Regarding the multiple html, head and body tags, what do we do to handle the multiple server server includes? For instance, I have Header.html and Footer.html

So when I include them within the main html file, I shall have 3 html tags, 3 head tags, 3 body tags.

With my page still under development, I know that with XHTML, this page will err. But will XHTML allow me includes for better maintainance as code is segregated into 3 seperate HTML files.

Thanks.
 
Don't put html, head, title, or body tags in the files that are included unless they actually contain the head, title, body, or absolute bottom of the page. I use SSI in all web design I do, and usually have the entire top down to, and including, the <body> tag in the header include, and the entire bottom of the page, including the </html>, in the bottom include.

I noticed that on your last example one of your includes didn't even get included, and the include instruction is still in the HTML.

Lee
 
Was this a port over from an original frames solution? Frames all point to their own html (or asp or whatever) files and are expected to have their own page markup. So, if you are now pulling in the frames via SSI, then you will need to fix the included files to not have that markup. Until you do that it's hard to predict what will happen.

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
I do not have any frames within my page. I have 3 div tags aligned horizontally. Where I show the content in the respective div tags.

Something like this:

Code:
header.html

div1                        div2                   div3

Footer.html

Anyway now I have removed all the markup tags from the includes so that the cohesive result has only one tag each of HTML, HEAD, TITLE and BODY.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top