We help IT Professionals succeed at work.

Microsoft Jscript error  object expected while debugging classic ASP

541 Views
Last Modified: 2013-12-24
Microsoft Jscript error Object exxpected

I am running an classic asp page which has some javascript functions, when I run the page I get an error stating

Microsoft Jscript error Object exxpected, and it happens at this line of code
<body OnLoad="SetParams()">

the script tag has the following code
<script language="Javascript"  type="text/javascript"  src="JScript/reg_form_process.js"></script>


Here is the code snippet
<%@ Language=VBScript %>
<%
Option Explicit
Response.Expires = 60
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"

If Session("VolunteerID")<>"" Then
      Response.Redirect "thankyou.asp"
End If

''#################### VARIABLES REQUIRED FOR REG FORM ####################
dim VolunteerID
dim RedirectTxt      ''page to redirect to after data is saved
dim SubmitTxt       ''page to submit registration page to for saving
dim ShowSubmit       ''True or False value indicating wether save panel is viewable on reg form
dim ShowShifts       ''True or False Value indicating wether form should show assigned shifts panel
dim FormLabel       ''Text To display at top of registraion form
dim strTemp       ''Misc string used for temp processing
dim strSQL
dim rsGetData
dim strSQL_Sup
dim rsGetData_Sup
dim NumOfPreDays
dim NumOfConventionDays
dim NumOfDays
dim ColWidth
dim Bgcolour
dim DayName
dim ShortDate
dim Date_Text()
dim Date_ID()
dim Vol_Available()
dim Vol_Assigned()
dim Temp_BGcolour
dim Vol_Skill_Assigned
dim Vol_This_Skill
dim Day_Check
dim Day_Disable
dim x
dim SkillCounter
dim Prefix
dim FirstName
dim MiddleName
dim LastName
dim BadgeTitle
dim Suffix
dim Email
dim Phone
dim AlternativePhone
dim AddressLine1
dim AddressLine2
dim City
dim State
dim ZipCode
dim Country
dim ParishID
dim NeedsHousing
dim CanProvidehousing
dim ProvideHousingOnly
dim MaximumNumberShifts
dim Comments


FormLabel="<span class=""regLabel3"">If you wish to volunteer at the , please complete the form below and click the 'Submit' button at the bottom of this page. Items marked </span><span class=""regLabel4"">*</span><span class=""regLabel3""> are required.<br>There is a link at the bottom of this page to view a printable form, which can be filled out by hand and mailed if preferred (additional instructions are included on the form). <a href=""http://www.adobe.com/products/acrobat/main.html"">Adobe Acrobat</a> is required to view .pdf files.<p></span>"
VolunteerID=""
RedirectTxt="thankyou.asp"
SubmitTxt="register_save.asp"
ShowSubmit="True"
ShowShifts="False"
''#################### END VARIABLES REQUIRED FOR REG FORM ####################
%>
<!--#include file ="Includes/volunteer_db_connect.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
      <title>Test Registration GC2006</title>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
      <meta name="author" content="JH">
      <meta name="description" content="Test Application">
      <meta name="date-created" content="2005-02-18">
      <meta name="robots" content="noindex,nofollow">
      <meta http-equiv="msthemecompatible" content="no">
      <meta HTTP-EQUIV="imagetoolbar" content="no">
      <link rel="stylesheet" href="Style/style.css" type="text/css">
      <script language="Javascript"  type="text/javascript"  src="JScript/reg_form_process.js"></script>
</head>
<body OnLoad="SetParams()">
<form name="register" action="register.asp" method="post" AUTOCOMPLETE="off">


The reg_form-process.js code snippet,

//onerror = handleErrors;
var msg = null;
var page_loading=true;
var form_name="";
var num_days=0;
var num_skills=0;
var set_am=false;
var set_pm=false;
var set_num_shifts=0;
var shift_count_am=1;
var shift_count_pm=1;
var num_shifts_set=false;

function SetParams()
{
      page_loading=false;
      form_name=document.forms[0].name;
      if(document.forms[0].numdays)
      {
            num_days=GetTextValue(form_name, "numdays");
            num_skills=GetTextValue(form_name, "numskills");
            NumShiftsSet();
      }
}
Comment
Watch Question

ZvonkoSystems architect
CERTIFIED EXPERT
Top Expert 2006

Commented:
Does your reg_form-process.js script contain definitions for the two functions used in SetParams(), I mean the functions GetTextValue() and NumShiftsSet()

Author

Commented:
Zvonko,
Yes, here is the code. Sorry that was jsut the snippet

function NumShiftsSet()
{
      var temp_num_shifts=GetTextValue(form_name, "MaxShifts");
      temp_num_shifts=SetNumbersOnly(temp_num_shifts);
      if(temp_num_shifts>9)
      {
            temp_num_shifts=9;
      }
      SetTextValue(form_name, "MaxShifts", temp_num_shifts);
      if(temp_num_shifts!="0")
      {
            num_shifts_set=true;
      }
}
function GetTextValue(form_name, text_name)
{
      //returns current text string value from named text input
      var Text_Value=eval("document." + form_name + "." + text_name + ".value");
      return Text_Value;
}

function SetTextValue(form_name, text_name, str_text)
{
      //sets form field text value
      eval("document." + form_name + "." + text_name + ".value=str_text");
}

Also on the submit button, I have a ValidateForm function which gives me the same error Object required

<td align="left" valign="top" colspan="3">
                                                      <span class="regLabel1">&nbsp;</span>
                                                      <input type="button" name="submit_form" value="Submit" class="regbutton1" OnClick="ValidateForm()">
                                                      <span class="regLabel3">&nbsp;<< Click here to submit your volunteer details</span>
                                                </td>

Do I have to mention at the begining of the .js file indicating this is Javascript

Currently there is no heading in the .js file
ZvonkoSystems architect
CERTIFIED EXPERT
Top Expert 2006

Commented:
No, you have not to tell in the js file that it is a script file. Only script content, no html.
But I see no errors so the only error can be that JScript/reg_form_process.js is NOT located in a subdirectory JScript below the actual page directory. Also be sure that lowercase and uppercase file name characters are correct handled by your web server.

Where is the function ValidateForm() defined?

Author

Commented:
The ValidateForm is defined in the same reg_form-process.js file with the other functions.
The structure of my web directory is GCV under which there are sub folders
GCV
..Admin
--Includes
..Jscript
--Images
--Style

and then there are asp pages under GCV
How do I verify that lowercase and uppercase file name characters are correct handled by  web server.
I did a visual check that the case sensitivity is fine with the names
Systems architect
CERTIFIED EXPERT
Top Expert 2006
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Zvonko,

I will give that a try and let you know, i amaway from my computer.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.