Object required -- JavaScript error in an ASP vbScript application

Posted on 2007-07-30
Last Modified: 2013-11-19
Hello Everyone, I have a page which posts to itself.  The purpose is to set the status, in other words change update the status on the database depending on which button is clicked: Open or Close

However, I get a JavaScript error:

Object required

 Line: 192

This is a line that has nothing to do with the code below, but I do have a lot of include files so I really do not know where line 192 is coming from& I do know that there is something wrong with this particular code because I you remove it the application works perfectly, but we cannot remove it& We had it so that the status would update correctly but they would update just by opening the page, what I need is the status to update when the correct button is clicked&. That is because if a person visits this page and does NOT click the button, then we do NOT want the form to update, it would be a huge error&. That is why I really need your help with this you and its particularly important that just visiting this page does not update the status& If you want I can show you the entire code, but its over 2000 lines long&

If it would be better to have the code post to another page, a little page that opens in a new window and says your page was correctly submitted, I would be willing to do that also, but as far as I know whether a page posts to itself or a diff page, the code is pretty much the same, its still request.form&The idea is that when the user clicks OPEN the form should OPEN, and the status should change to (OPEN) but the OPEN button should disappear and be replaced by the CLOSED button.  This is because now that the form is open the next step would be to close it, and vice versa& There is a button that can stop this open and close from happening, and if that button is clicked, then BOTH buttons disappear, but that part works, so I do not need help with it&.  Can U help me figure this one?

NOTE: This page posts to itself, I think when it does this something is not working properly because we are clicking submit buttons and yet they do not make a difference, they do not call the ASP code and to test it we did a response.write request.form("hideOpenBtn") and we did not get any value, not even 0 which is the default value for this hidden variable


<form action="52-readOnly.asp" id="OPICForm" name="OPICForm" method="post" onSubmit="return ValidateSubmit();">

<input name="hideOpenBtn" type="hidden" value="0" />

<script language="JavaScript" type="text/JavaScript">
//Angie H.  ------   OPENS THE APPLICATION
      function openBtn(){
            document.OPICForm.hideOpenBtn.value = 1;
//In JavaScript confirm shows OK and CANCEL in the pop up, which is exactly what we need, if they click OK, then the update should take place, if they click Cancel than nothing should happen&

            confirm("Are you sure you want to OPEN this form? If Yes, click OK, then click the Return to Registrations/Applications Report link at the top of the page.");
            document.getElementById("of").style.visibility = "hidden";
            document.getElementById("cf").style.visibility = "visible";            
            return false;
      function closeBtn(){
            document.OPICForm.hideOpenBtn.value = 2;
            confirm("Are you sure you want to CLOSE this form?  If Yes, click OK, then click the Return to Registrations/Applications Report link at the top of the page.");
            document.getElementById("cf").style.visibility = "hidden";
            document.getElementById("of").style.visibility = "visible";
            return false;

<div name = ocButtons id = ocButtons style="VISIBILITY: visible">
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<% IF IStatusID >3 THEN %>
  <% IF (IStatusID =4 OR IStatusID =5) THEN %>
    <input type = "submit" value="&nbsp;&nbsp;Close Form&nbsp;&nbsp;" name = "cf" id = "cf" type="button"  onClick = "closeBtn(); "/>&nbsp;
  <% ELSE %>
    <input type "submit" value="&nbsp;&nbsp;Open Form&nbsp;&nbsp;" name = "of" id = "of" type="button"  onClick = "openBtn(); " />&nbsp;
  <% END IF %>
<% END IF %>
if(request.form("hideOpenBtn") = 1) then
      objConn.execute("UPDATE Application SET FK_ApplicationStatusID=6, Submitted_ts='" & now() & "' WHERE PK_ApplicationID=" & iApplicationID)
elseif(request.form("hideOpenBtn") = 2) then      
      objConn.execute("UPDATE Application SET FK_ApplicationStatusID=5, Submitted_ts='" & now() & "' WHERE PK_ApplicationID=" & iApplicationID)
end if
Question by:Gemini532
    LVL 14

    Assisted Solution

    I'm confused...
    You have no way of determining the line it is choking on?
    when exactly do you see the described error?
    when the page loads, when a button is clicked, which button?
    if when a button is clicked, are there any script errors from the page load? that might mean there is some misformatted code in the page, or in one of the include files?
    if you could put the page somewhere where we could reach it on web, or post all the source somewhere, that would probably be the most helpful for us to be able to help you.

    also, just a comment on the confirms, it seems there is no logic used, so they work as is just like an alert would.

    usually, a block of code using a confirm would look more like:

    if (confirm("are you sure?")) {
    //do something
    //do something else

    Accepted Solution

    Have you written all your functions required and declare all your objects like objConn??
    I do not see the function ValidateSubmit() anywhere in your post. Perhaps that was the one causing the error.

    Author Comment

    If I include all the function that I already know work prefectly, it will be over 3000 lines of code!!!!  I need help with the code  I included becuase I know for a fact the error is from there....
    The idea is to get the BUTTONS CLOSE and OPEN to update the database with the Status Value: SET FK_ApplicationStatusID=6  

    When the button is CLOSED the status Value should be 6 when the button is OPEN the status value should be 5

    However, I am running into a JavaScript error, and I believe it is caused by the way this code is written....


    Author Comment

    Would it make a difference if the code was posted in another page rather than the page posting to itself?!!?
    LVL 14

    Expert Comment

    no, I don't think so, but I've been wrong before..., but, it seems the problem is with the script in that page, and if it won't post, it really doesn't matter where it won't post to, does it???

    Author Comment

    Hi steveberzins:
    We posted the code to a new page and we fixed in 5 min

    However I gave everyone points for helping... since I cannot give myself point... hehehe  

    Expert Comment

    Cool.. Glad to hear that you've resolve your problem.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
    JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
    Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now