• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1673
  • Last Modified:

JavaScript function causing "Object Expected" Error

I've looked at this for about 30 minutes now.  For some reason, on the line where my form tag start (where it calls the JavaScript functin), it gives me that error.  So I assume the error is within the JavaScript function iteself but I can't find it:

Sub AddResource

      Response.Write("    <td align=""right"" valign=""top"">" & vbCrLf) '#### Main Column 2 Start
      Response.Write("       <table border=""0""  bordercolor=""green""  cellspacing=""0"" cellpadding=""0"" name=""Data"">" & vbCrLf)
      Response.Write("         <tr>" & vbCrLf)
      Response.Write("            <td align=""left"" valign=""top"" class=""rptheader"">Add New Resource</td>" & vbCrLf)
      Response.Write("            </td>" & vbCrLf)
      Response.Write("         </tr>" & vbCrLf)
      Response.Write("         <tr>" & vbCrLf)
      Response.Write("            <td align=""right"" valign=""top"">" & vbCrLf)
      Response.Write("                        <form action=""/sss/sss.asp?action=addresource"" method=""post"" name=""newresource"" OnSubmit=""return CheckNewResource();"">" & vbCrLf)
      Response.Write("                         <input type=""hidden"" name=""write"" value=""1"">" & vbCrLf)
      Response.Write("                          <table border=""0"" cellspacing=""0"" cellpadding=""3"">" & vbCrLf)
      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                      <td align=""right"" class=""required""><strong><a href=""/sss/sss.asp?item=subject"" onClick=""popup('/sss/sss.asp?item=subject'); return false;"">Name</a>:</strong></td>" & vbCrLf)
      Response.Write("                                      <td colspan=""4"" align=""left""><input type=""text""  name=""resourcename"" size=""20"" maxlength=""50"">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>" & vbCrLf)
      Response.Write("                                 </tr>" & vbCrLf)

      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                        <td align=""right"" valign=""middle"" width=""35%"" class=""required""><strong><a href=""/erd/help_erd.asp?item=subject"" onClick=""popup('/sss/sss.asp?item=Resourcetype'); return false;"">Resource Type</a></td>" & vbCrLf)
      Response.Write("                                      <td align=""left""  valign=""top""><select name=""resourcetype"">" & vbCrLf)
      Response.Write("                                            <option value="""">--Resource Type--</option>" & vbCrLf)
                                                                        strSQL = "sp_Get_Resource_Types"
                                                                        Set Query = objConnection.Execute(strSQL)
                                                                        If NOT Query.EOF Then
                                                                              Do While NOT Query.EOF
      Response.Write("                                            <option value=""" & Query("ResourceTypeID") & """")
                                                                                    Response.Write (">" & Query("ResourceType") & "</option>" & vbCrLf)
                                                                                    If Query.EOF Then Exit Do
                                                                                    Query.MoveNext
                                                                              Loop
                                                                              Else
      Response.Write("                                                <option value="""">No types found</option>" & vbCrLf)
                                                                        End If
                                                                                    Query.Close
                                                                                    Set Query=Nothing
      Response.Write("                                    </select></td>" & vbCrLf)
      Response.Write("                                </tr>" & vbCrLf)

      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                      <td align=""right"" class=""required"" valign=""middle""><strong><a href=""/erd/help_erd.asp?item=subject"" onClick=""popup('/sss/sss.asp?item=subject'); return false;"">Serial #</a>:</strong></td>" & vbCrLf)
      Response.Write("                                      <td colspan=""4"" align=""left""><input type=""text"" name=""serial"" size=""20"" maxlength=""50"">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>" & vbCrLf)
      Response.Write("                                 </tr>" & vbCrLf)
      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                        <td align=""right"" valign=""middle"" width=""35%"" class=""required""><strong><a href=""/sss/sss.asp?item=location"" onClick=""popup('/sss/sss.asp?item=location'); return false;"">Location</a></td>" & vbCrLf)
      Response.Write("                                      <td align=""left""  valign=""top""><select name=""location"" size=""1"">" & vbCrLf)
      Response.Write("                                            <option value="""">--Location--</option>" & vbCrLf)
                                                                        strSQL = "sp_Get_Location"
                                                                        Set Query = objConnection.Execute(strSQL)
                                                                        If NOT Query.EOF Then
                                                                              Do While NOT Query.EOF
      Response.Write("                                            <option value=""" & Query("LocationID") & """")
                                                                                    Response.Write (">" & Query("LocationName") & "</option>" & vbCrLf)
                                                                                    Query.MoveNext
                                                                              Loop
                                                                              Else
      Response.Write("                                                <option value="""">No Locations found</option>" & vbCrLf)
                                                                        End If
                                                                                    Query.Close
                                                                                    Set Query=Nothing
      Response.Write("                                    </select></td>" & vbCrLf)
      Response.Write("                                </tr>" & vbCrLf)

      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                        <td align=""right"" valign=""middle"" width=""35%"" class=""required""><strong><a href=""/sss/sss.asp?item=subject"" onClick=""popup('/sss/sss.asp?item=OS'); return false;"">OS</a></td>" & vbCrLf)
      Response.Write("                                      <td align=""left""  valign=""top""><select name=""os"" size=""1"">" & vbCrLf)
      Response.Write("                                            <option value="""">--OS--</option>" & vbCrLf)
                                                                        strSQL = "sp_Get_OS"
                                                                        Set Query = objConnection.Execute(strSQL)
                                                                        If NOT Query.EOF Then
                                                                              Do While NOT Query.EOF
      Response.Write("                                            <option value=""" & Query("OSID") & """")
                                                                                    Response.Write (">" & Query("OSName") & "</option>" & vbCrLf)
                                                                                    Query.MoveNext
                                                                              Loop
                                                                              Else
      Response.Write("                                                <option value="""">No types found</option>" & vbCrLf)
                                                                        End If
                                                                                    Query.Close
                                                                                    Set Query=Nothing
      Response.Write("                                    </select></td>" & vbCrLf)
      Response.Write("                                </tr>" & vbCrLf)

      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                        <td align=""right"" valign=""top"" width=""35%"" class=""required""><strong><a href=""/sss/sss.asp?item=subject"" onClick=""popup('/sss/sss.asp?item=brand'); return false;"">Brand</a></td>" & vbCrLf)
      Response.Write("                                      <td align=""left""  valign=""top""><select name=""brand"" size=""1"">" & vbCrLf)
      Response.Write("                                            <option value="""">--Brand--</option>" & vbCrLf)
                                                                        strSQL = "sp_Get_Brand"
                                                                        Set Query = objConnection.Execute(strSQL)
                                                                        If NOT Query.EOF Then
                                                                              Do While NOT Query.EOF
      Response.Write("                                            <option value=""" & Query("BrandID") & """")
                                                                                    Response.Write (">" & Query("BrandName") & "</option>" & vbCrLf)
                                                                                    Query.MoveNext
                                                                              Loop
                                                                              Else
      Response.Write("                                                <option value="""">No Brands found</option>" & vbCrLf)
                                                                        End If
                                                                                    Query.Close
                                                                                    Set Query=Nothing
      Response.Write("                                    </select></td>" & vbCrLf)
      Response.Write("                                </tr>" & vbCrLf)

      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                        <td align=""right"" valign=""top"" width=""35%"" class=""required""><strong><a href=""/sss/sss.asp?item=subject"" onClick=""popup('/sss/sss.asp?item=cputype'); return false;"">CPU Type</a></td>" & vbCrLf)
      Response.Write("                                      <td align=""left""  valign=""top""><select name=""cputype"" size=""1"">" & vbCrLf)
      Response.Write("                                            <option value="""">--CPU--</option>" & vbCrLf)
                                                                        strSQL = "sp_Get_CPUType"
                                                                        Set Query = objConnection.Execute(strSQL)
                                                                        If NOT Query.EOF Then
                                                                              Do While NOT Query.EOF
      Response.Write("                                            <option value=""" & Query("CPUTypeID") & """")
                                                                                    Response.Write (">" & Query("CPUType") & "</option>" & vbCrLf)
                                                                                    Query.MoveNext
                                                                              Loop
                                                                              Else
      Response.Write("                                                <option value="""">No Types found</option>" & vbCrLf)
                                                                        End If
                                                                                    Query.Close
                                                                                    Set Query=Nothing
      Response.Write("                                    </select></td>" & vbCrLf)
      Response.Write("                                </tr>" & vbCrLf)

      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                        <td align=""right"" valign=""top"" width=""35%"" class=""required""><strong><a href=""/sss/sss.asp?item=cpuspeed"" onClick=""popup('/sss/sss.asp?item=cpuspeed'); return false;"">CPU Speed</a></td>" & vbCrLf)
      Response.Write("                                      <td align=""left""  valign=""top""><select name=""cpuspeed"" size=""1"">" & vbCrLf)
      Response.Write("                                            <option value="""">--CPU Speed--</option>" & vbCrLf)
                                                                        strSQL = "sp_Get_CPUSpeed"
                                                                        Set Query = objConnection.Execute(strSQL)
                                                                        If NOT Query.EOF Then
                                                                              Do While NOT Query.EOF
      Response.Write("                                            <option value=""" & Query("CPUSpeedID") & """")
                                                                                    Response.Write (">" & Query("SpeedValue") & "</option>" & vbCrLf)
                                                                                    Query.MoveNext
                                                                              Loop
                                                                              Else
      Response.Write("                                                <option value="""">No Speeds found</option>" & vbCrLf)
                                                                        End If
                                                                                    Query.Close
                                                                                    Set Query=Nothing
      Response.Write("                                    </select></td>" & vbCrLf)
      Response.Write("                                </tr>" & vbCrLf)

      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                        <td align=""right"" valign=""top"" width=""35%"" class=""required""><strong><a href=""/sss/sss.asp?item=ramamount"" onClick=""popup('/sss/sss.asp?item=ramamount'); return false;"">Disk Space</a></td>" & vbCrLf)
      Response.Write("                                      <td align=""left""  valign=""top""><select name=""hdsize"" size=""1"">" & vbCrLf)
      Response.Write("                                            <option value="""">--Space (total all drives)--</option>" & vbCrLf)
                                                                        strSQL = "sp_Get_DiskSize"
                                                                        Set Query = objConnection.Execute(strSQL)
                                                                        If NOT Query.EOF Then
                                                                              Do While NOT Query.EOF
      Response.Write("                                            <option value=""" & Query("DiskSizeID") & """")
                                                                                    Response.Write (">" & Query("DiskSize") & "</option>" & vbCrLf)
                                                                                    Query.MoveNext
                                                                              Loop
                                                                              Else
      Response.Write("                                                <option value="""">No Sizes found</option>" & vbCrLf)
                                                                        End If
                                                                                    Query.Close
                                                                                    Set Query=Nothing
      Response.Write("                                    </select></td>" & vbCrLf)
      Response.Write("                                </tr>" & vbCrLf)

      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                        <td align=""right"" valign=""top"" width=""35%"" class=""required""><strong><a href=""/sss/sss.asp?item=ramamount"" onClick=""popup('/sss/sss.asp?item=ramamount'); return false;"">RAM</a></td>" & vbCrLf)
      Response.Write("                                      <td align=""left""  valign=""top""><select name=""ramamount"" size=""1"">" & vbCrLf)
      Response.Write("                                            <option value="""">--RAM Amount--</option>" & vbCrLf)
                                                                        strSQL = "sp_Get_RAMAmount"
                                                                        Set Query = objConnection.Execute(strSQL)
                                                                        If NOT Query.EOF Then
                                                                              Do While NOT Query.EOF
      Response.Write("                                            <option value=""" & Query("RAMAmountID") & """")
                                                                                    Response.Write (">" & Query("RAMAmount") & "</option>" & vbCrLf)
                                                                                    Query.MoveNext
                                                                              Loop
                                                                              Else
      Response.Write("                                                <option value="""">No Amounts found</option>" & vbCrLf)
                                                                        End If
                                                                                    Query.Close
                                                                                    Set Query=Nothing
      Response.Write("                                    </select></td>" & vbCrLf)
      Response.Write("                                </tr>" & vbCrLf)

      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                        <td align=""right"" valign=""top"" width=""35%"" class=""required""><strong><a href=""/sss/sss.asp?item=subject"" onClick=""popup('/sss/sss.asp?item=softwareinstalled'); return false;"">Software<br>Installed</a></td>" & vbCrLf)
      Response.Write("                                      <td align=""left""  valign=""top""><select name=""software"" size=""10"" multiple>" & vbCrLf)
      Response.Write("                                            <option value=""""></option>" & vbCrLf)
                                                                        strSQL = "sp_Get_Software"
                                                                        Set Query = objConnection.Execute(strSQL)
                                                                        If NOT Query.EOF Then
                                                                              Do While NOT Query.EOF
      Response.Write("                                            <option value=""" & Query("SoftwareID") & """")
                                                                                    Response.Write (">" & Query("SoftwareName") & "</option>" & vbCrLf)
                                                                                    Query.MoveNext
                                                                              Loop
                                                                              Else
      Response.Write("                                                <option value="""">No Names found</option>" & vbCrLf)
                                                                        End If
                                                                                    Query.Close
                                                                                    Set Query=Nothing
      Response.Write("                                    </select></td>" & vbCrLf)
      Response.Write("                                </tr>" & vbCrLf)
      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                      <td></td>" & vbCrLf)
      Response.Write("                                      <td colspan=""4""><input type=""submit"" name=""Submit"" value=""Add"" class=""submitbutton""> &nbsp;<input type=""button"" name=""cancel"" value=""Cancel"" class=""submit_cancel"" OnClick=""window.open('/sss/sss.asp?status=rc', '_self')""></td>" & vbCrLf)
      Response.Write("                                 </tr>" & vbCrLf)
      Response.Write("                                 <tr><td colspan=""6""><p class=""font-one"" align=""center""><span class=""required"">Fields listed in dark red are required.</span><td><tr>" & vbCrLf)
      Response.Write("                       </table>" & vbCrLf)
      Response.Write("                       </form>" & vbCrLf)
      Response.Write("          </table>" & vbCrLf)
      Response.Write("    </td>" & vbCrLf) '#### Main Column 2 End
      Response.Write("   </tr>" & vbCrLf)
      Response.Write("</table>" & vbCrLf)


End Sub


Sub SubmitResource

      Dim strCreateDate, intCreatedByID, intLocationID, intResourceTypeID, strResourceName, intCPUTypeID, intCPUSpeedID, intBrandID, intRAMAmountID, intOSID, strSerialNum, intDiskSizeID, intNewResourceID, intOwnerID

      strCreateDate = Now()
      intOwnerId = Session("EmployeeID")
      intCreatedByID = Session("EmployeeID")
      intLocationID = Request("location")
      intDiskSizeID = Request("hdsize")
      intResourceTypeID      = Request("resourcetype")
      strResourceName = Trim(Request("resourcename"))
      intCPUTypeID = Request("cputype")
      intCPUSpeedID = Request("cpuspeed")
      intBrandID = Request("brand")
      intRAMAmountID = Request("ramamount")
      intOSID = Request("os")
      strSerialNum = Trim(Request("serial"))

      If CheckForBlankValues(intOwnerId & "|||" & intCreatedByID & "|||" & intLocationID & "|||" & intDiskSizeID & "|||" & intResourceTypeID & "|||" & strResourceName & "|||" & intCPUTypeID & "|||" & intCPUSpeedID & "|||" & intBrandID & "|||" & intRAMAmountID & "|||" & intOSID & "|||" & strSerialNum) Then

            strSQL = "sp_Add_Resource"
            strSQL = strSQL & " @OwnerID  = '" & Cint(intOwnerID) & "',"
            strSQL = strSQL & " @CreatedByID  = '" & Cint(intCreatedByID) & "',"
            strSQL = strSQL & " @LocationID = '" & Cint(intLocationID)  & "',"
            strSQL = strSQL & " @ResourceTypeID = '" & Cint(intResourceTypeID)  & "',"
            strSQL = strSQL & " @ResourceName = '" & strResourceName & "',"
            strSQL = strSQL & " @DiskSizeID = '" & Cint(intDiskSizeID)  & "',"
            strSQL = strSQL & " @CPUTypeID = '" & Cint(intCPUTypeID) & "',"
            strSQL = strSQL & " @CPUSpeedID = '" & Cint(intCPUSpeedID)  & "',"
            strSQL = strSQL & " @BrandID = '" & Cint(intBrandID) & "',"
            strSQL = strSQL & " @RAMAmountID = '" & Cint(intRAMAmountID) & "',"
            strSQL = strSQL & " @SerialNumber = '" & strSerialNum  & "',"
            strSQL = strSQL & " @CreatedDate = '" & strCreateDate & "',"
            strSQL = strSQL & " @OSID = '" & intOSID & "'"

            Set Query = objConnection.Execute(strSQL)

            Session("LastResourceID") = Query("NewResourceID")

            intNewResourceID = Session("LastResourceID")

            Set Query = Nothing

            if len(trim(request("software")))>0 then
              Dim strMySelectValue, arrSoftwareList
              strMySelectValue = request("software")
              arrSoftwareList = split(strMySelectValue, ",")
              for i=0 to ubound(arrSoftwareList)
                        strSQL = "sp_Add_Software @SoftwareID=" & arrSoftwareList(i) & ", @NewResourceID=" & intNewResourceID
                        Set Query = objConnection.Execute(strSQL)
              next
            end if

            Response.Redirect ("/erd/main.asp")
      Else
            Response.Write("<p class=""error"">Error -- All Required Fields Not Completed</p><p>Please use your back button to return to the form and complete all required fields.</p>" & vbCrLf)
      End If


%>
<script type="text/javascript">
<!--
var f = document.newresource;

function CheckNewResource() {

      if (f.resourcename.value.length < 5) {
            alert("Please enter a valid Resource Name");
            f.resourcename.focus();
            return false;
      } else if (f.resourcetype.options[f.resourcetype.selectedIndex].value.length < 1) {
            alert("Please select the type of Resource Type");
            f.resourcetype.focus();
            return false;
      } else if (f.serial.value.length < 5) {
            alert("Please enter a valid Serial #");
            f.serial.focus();
            return false;
      } else if (f.location.options[f.location.selectedIndex].value.length < 1) {
            alert("Please select the Location of the Resource");
            f.location.focus();
            return false;
      } else if (f.os.options[f.os.selectedIndex].value.length < 1) {
            alert("Please select the OS of the Resource");
            f.os.focus();
            return false;
      } else if (f.brand.options[f.brand.selectedIndex].value.length < 1) {
            alert("Please select the Brand of the Resource");
            f.brand.focus();
            return false;
      } else if (f.cputype.options[f.cputype.selectedIndex].value.length < 1) {
            alert("Please select the CPU Type of the Resource");
            f.cputype.focus();
            return false;
      } else if (f.cpuspeed.options[f.cpuspeed.selectedIndex].value.length < 1) {
            alert("Please select the CPU Speed of the Resource");
            f.cpuspeed.focus();
            return false;
      } else if (f.hdsize.options[f.hdsize.selectedIndex].value.length < 1) {
            alert("Please select the Hard Drive Size (in Gigibytes) of the Resource");
            f.hdsize.focus();
            return false;
      } else if (f.ramamount.options[f.ramamount.selectedIndex].value.length < 1) {
            alert("Please select the RAM Amount of the Resource");
            f.ramamount.focus();
            return false;
      } else if (f.software.options[f.software.selectedIndex].value.length < 1) {
            alert("Please select any installed Software");
            f.software.focus();
            return false;
      }

      // Prevent multiple form submissions
      f.Submit.value = "Resource Submitted, Please Wait...";
      f.Submit.disabled = true;
      return true;
}
// -->
</script>
<%

End Sub


%>
0
dba123
Asked:
dba123
  • 35
  • 12
  • 5
  • +2
3 Solutions
 
dperishCommented:
Thats alot of code dude, should post line numbers and exact error message with this gig.
0
 
dba123Author Commented:
that's the problem, it told me it was this line as stated:

Response.Write(" <form action=""/erd/main.asp?action=addresource"" method=""post"" name=""newresource"" OnSubmit=""return CheckNewResource();"">" & vbCrLf)

all that leads me to is my JavaScript function....I posted my table code so that you could see that my fieldnames were correct where javascript is referencing them.
0
 
dba123Author Commented:
the exact error message is in my subject line
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
VirusMinusCommented:
to debug Javascript errors, view the page source after it renders. Copy this source paste into an editor and track down the line..
0
 
dba123Author Commented:
figured it out..I had a few other forms referencing functions that didn't exist...
0
 
dba123Author Commented:
VirusMinus, that's what I was doing before I posted....Thanks for the help so far but I will delete this since I found it.
0
 
dba123Author Commented:
Ok, I guess I didn't solve it...still in the same boat.  I already tried to look at the page source and that is where I was able to figure out where the error occured...where I just stated.
0
 
dba123Author Commented:
It is something to do wtih my JavaScript function but I don't know what is wrong with it....what object could it be expecting here that isn't there?
0
 
VirusMinusCommented:
Ok try calling your javascript function on the onClick event of the submit button.

Also when I have a lot of HTML code i avoid doing response.write, i just put it as is between %> and <%
0
 
dba123Author Commented:
>>VirusMinus   yea, you keep telling me but I am sticking to the standard and am now used to Response.Write.
0
 
dba123Author Commented:
>>>try calling your javascript function on the onClick event of the submit button

that wouldn't make any difference.  It isn't a problem that it's not being called, it is that there is something that the function doesn't like or is expecting ("object expected") when it is called that is the problem and I have no clue what because I've eyeballed the function along wtih the source a million times.
0
 
VirusMinusCommented:
I'm assuming the error goes away when you remove the Javascript function?

I alos noticed that the line var f = document.newresource; is outside the javascript function but it looks like you're using it inside the function. And when you call the function is does'nt see the above line, hence 'object expected' also the last few lines ->

     // Prevent multiple form submissions
     f.Submit.value = "Resource Submitted, Please Wait...";
     f.Submit.disabled = true;
     return true;

are outside the function. are these meant to be inside? If not they will just be executed once.

0
 
dba123Author Commented:
>>>I'm assuming the error goes away when you remove the Javascript function?

Correct

>>>var f = document.newresource; is outside the javascript function

I've used this function and others and the f is definitely accessible by the function.  You don't have to have it insided the function to work.
0
 
VirusMinusCommented:
Would you mind trying to see if putting it inside has any effect?

Also try calling the function without return. like onSubmit="CheckNewResource();"
0
 
dba123Author Commented:
I tried it, had no effect.  And I'd rather keep the onSubmit in my form definition.  Why would it make a difference??
0
 
dba123Author Commented:
sorry, hold on, let me try without return....but that's how I've always done it in the past.
0
 
dba123Author Commented:
taking out the return doesn't do anything different for the error.
0
 
ap_sajithCommented:
you are getting the 'object expected' error because the function could not be located or one of the field names could not be located.

Make sure that you are calling both subroutines.

You can confirm this by viewing the source of the rendered HTML.

Also, make sure that you are including any .JS files that might be required.

Please try and post the code for the page that invoked the above two subroutines.

Cheers!!
0
 
VirusMinusCommented:
try putting the javascript function in the <head> </head> tags
0
 
dba123Author Commented:
ap_sajith, what do you mean by both subroutines..can you be specific?  I am only calling one sub here
0
 
dba123Author Commented:
>>>try putting the javascript function in the <head> </head> tags  
there is no way, I have many pages going on and each page has it's own javascript functions.  I have always been able to include a JavaScript function within my ASP (outside the %>)

0
 
ap_sajithCommented:
@dba123, You have defined two subroutines [SubmitResource] & [AddResource]

Make sure that you are calling both the subroutines in your asp page. I can double check if you post the code from which you are calling the above two subroutines.

Thanks!
0
 
ap_sajithCommented:
BTW.. there is no need to put Javascript inside the head tag. What you have done is perfectly alright and should be functioning smoothly.

Cheers!!
0
 
dba123Author Commented:
I"m definitely submitting both forms....it worked fine before I added this JavaScript.
0
 
dba123Author Commented:
even if I get rid of all the error checking and reduce it down to just checking one text field, I still get the Object Expected error.  I tried changing my Javascript function to this:

<script type="text/javascript">
<!--

var f = document.newresource;

function CheckNewResource() {

      if (f.resourcename.value.length < 5) {
            alert("Please enter a valid Resource Name");
            f.resourcename.focus();
            return false;
      }
      return true;
}
// -->
</script>

still same error.
0
 
dba123Author Commented:
aj....Ok man, I'm warning you, this page is huge...you asked for it.  I'd advise that you copy and past into your own text editor due to all the indenting I do, it looks a mess in EE's small posting area.  

Also, if you have any pointers on how I can more organize my code, feel free in general.

This is my main.asp pae which calls a bunch of stuff:

<!--#include virtual="/sss/includes/functions.asp" -->
<% strPageTitle = " | Home" %>
<!--#include virtual="/sss/includes/header.asp" -->


<%
Response.Write("<h3>Welcome, " & Session("UserName") & "</h3>" & vbCrLf)

Dim ChangeRequestID, bolHasApprovals, bolHasAssigned, bolOpenContent, bolClosedContent, arrCSS, action, act, strRowClass, ResourceID

strRowClass = GetRowClassSM(i)

action = Trim(Request.QueryString("action"))
act = Trim(Request.QueryString("act"))


      If action = "gethardform" Then
            Call ShowUserMain
                Call AddResource
          elseif action="getharddesc" Then
                   Call ShowResourceDesc
                Call ShowUserMain
               Call ShowLastestAdded
      elseif Request.Form("write") = "1" Then
            Call SubmitResource
      else
            Call ShowUserMain
            Call ShowLastestAdded
      End If


Sub ShowUserMain

      '###### Show All PCs

      Dim ResourceID

      strSQL = "sp_Get_EngineeringPCs"
      Set Query = objConnection.Execute(strSQL)


      Response.Write("<table border=""0"" width=""100%"" bordercolor=""red""  cellspacing=""2"" cellpadding=""0"" name=""Data"">" & vbCrLf)
      Response.Write("<tr colspan=""3""><td align=""left"" ><a href=""/sss/main.asp""><b>Home</b></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=""/sss/main.asp?action=gethardform""><b>Add New Resource</b></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=""/sss/main.asp?action=gethardform""><b>Search<img src=""/sss/images/search.gif"" border=""0""></b></a><!--&nbsp;&nbsp;&nbsp;&nbsp;<a href=""/sss/images/map_firstFloor.jpg"" target=""_blank""><b>Map_1stFloor</b></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=""/sss/images/map_secondFloor.jpg"" target=""_blank""><b>Map_2nd Floor</b></a>-->&nbsp;&nbsp;&nbsp;&nbsp;<a href=""/sss/main.asp?action=gethardform""><b>sss</b></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=""/sss/main.asp?action=gethardform""><b>Suggestions</b>" & vbCrLf)
      Response.Write("<tr colspan=""3""><td align=""left"" valign=""top""><img src=""/sss/images/gr.gif"" border=""0"">Available&nbsp;&nbsp;&nbsp;<img src=""/sss/images/bl.gif"" border=""0"">Used by you&nbsp;&nbsp;&nbsp;<img src=""/sss/images/rd.gif"" border=""0"">Full" & vbCrLf)


      Response.Write("  <tr>" & vbCrLf)
      Response.Write("    <td align=""left"" valign=""top"">" & vbCrLf) '##### Main Column 1 Start

      Response.Write("       <table border=""0"" bordercolor=""green""  cellspacing=""0"" cellpadding=""0"" name=""Data"">" & vbCrLf)
      Response.Write("         <tr>" & vbCrLf)
      Response.Write("            <td align=""left"" valign=""top"">" & vbCrLf)  '####Col1 Start

      Response.Write("                        <table border=""0"" bordercolor=""yellow"" cellspacing=""1"" cellpadding=""3"">" & vbCrLf)
      Response.Write("                          <tr>" & vbCrLf)
      Response.Write("                                    <td align=""left"" valign=""bottom"" class=""rptheader2"" colspan=""4"">All Resources<nobr></td>" & vbCrLf)
      Response.Write("                          </tr>" & vbCrLf)
      Response.Write("                          <tr class=""rpttableheader"">" & vbCrLf)
      Response.Write("                                 <td valign=""bottom"" align=""center"">Name<nobr></td>" & vbCrLf)
      Response.Write("                                 <td valign=""bottom"" align=""center"">Location<nobr></td>" & vbCrLf)
      Response.Write("                                 <td valign=""bottom"" align=""center"">OS<nobr></td>" & vbCrLf)
      Response.Write("                                 <td valign=""bottom"" align=""center"">Status<nobr></td>" & vbCrLf)
      Response.Write("                          </tr>" & vbCrLf)
                                                If NOT Query.EOF Then
                                                      Do While NOT Query.EOF
                                                            strRowclass = GetrowclassSM(i)
                                                            i = i + 1
                                                            ResourceID = Query("ResourceID")
      Response.Write("                            <tr>" & vbCrLf)
      Response.Write("                                   <td align=""left"" valign=""top"" class=""" & strRowclass & """><a href=""/sss/main.asp?action=getharddesc&hid=" & Query("ResourceID") & """>" & Query("ResourceName") & "</a></td>" & vbCrLf)
      Response.Write("                                   <td align=""left"" valign=""top"" class=""" & strRowclass & """>" & Query("LocationName") & "</td>" & vbCrLf)
      Response.Write("                                   <td align=""left"" valign=""top"" class=""" & strRowclass & """>" & Query("OSName") & "</td>" & vbCrLf)
      Response.Write("                             <td align=""center"" valign=""top"" class=""" & strRowclass & """><a href=""/sss/main.asp?action=getharddesc&hid=" & Query("ResourceID") & """>" & StatusColor(Session("EmployeeID"), ResourceID) & "</a></td>" & vbCrLf)
      Response.Write("                            </tr>" & vbCrLf)
                                                            Query.MoveNext
                                                      Loop
                                                      Query.Close
                                                      Set Query=Nothing
                                                Else
      Response.Write("                            <tr>" & vbCrLf)
      Response.Write("                                   <td align=""left"" valign=""top"" class=""" & strRowclass & """ colspan=""4"">no records found</td>" & vbCrLf)
      Response.Write("                            </tr>" & vbCrLf)
                                                End If

      Response.Write("                        </table>" & vbCrLf)

      Response.Write("            </td>" & vbCrLf) '####Col1 End

      '########## Resource I Created

      strSQL = "sp_Get_Resources_CreatedBy_Me @CreatedByID=" & Session("EmployeeID")
      Set Query = objConnection.Execute(strSQL)

      Response.Write("            <td align=""right"" valign=""top"">" & vbCrLf)  '####Col2 Start

            Response.Write("                  <table border=""0"" bordercolor=""yellow"" cellspacing=""1"" cellpadding=""3"">" & vbCrLf)
            Response.Write("                    <tr>" & vbCrLf)
            Response.Write("                              <td align=""left"" valign=""top"" class=""rptheader3"" colspan=""4"">Resources I Created</td>" & vbCrLf)
            Response.Write("                    </tr>" & vbCrLf)
            Response.Write("                    <tr class=""rpttableheader"">" & vbCrLf)
            Response.Write("                           <td valign=""bottom"" align=""center"">Name<nobr></td>" & vbCrLf)
            Response.Write("                           <td valign=""bottom"" align=""center"">Location<nobr></td>" & vbCrLf)
            Response.Write("                          <td valign=""bottom"">Status<nobr></td>" & vbCrLf)
            Response.Write("                    </tr>" & vbCrLf)
                                                      If NOT Query.EOF Then
                                                            Do While NOT Query.EOF
                                                                  strRowclass = GetrowclassSM(i)
                                                                  i = i + 1
                                                                  ResourceID = Query("ResourceID")
            Response.Write("                      <tr>" & vbCrLf)
            Response.Write("                             <td align=""left"" valign=""top"" class=""" & strRowclass & """><A HREF=""/sss/main.asp?action=getharddesc&hid=" & Query("ResourceID") & """>" & Query("ResourceName") & "</a></td>" & vbCrLf)
            Response.Write("                             <td align=""left"" valign=""top"" class=""" & strRowclass & """>" & Query("LocationName") & "</td>" & vbCrLf)
            Response.Write("                             <td align=""center"" valign=""top"" class=""" & strRowclass & """>" & StatusColor(Session("EmployeeID"), ResourceID) & "</td>" & vbCrLf)
            Response.Write("                      </tr>" & vbCrLf)
                                                                  Query.MoveNext
                                                            Loop
                                                      Else
            Response.Write("                      <tr>" & vbCrLf)
            Response.Write("                             <td align=""left"" valign=""top"" class=""" & strRowclass & """ colspan=""4"">no records found</td>" & vbCrLf)
            Response.Write("                      </tr>" & vbCrLf)
                                                      End If

            Response.Write("                  </table>" & vbCrLf)

            Response.Write("        </td>" & vbCrLf) '####Col2 End

      If action<> "gethardform" Then


            Response.Write("        <td align=""right"" valign=""top"">" & vbCrLf) '####Col3 Start
            Response.Write("                  <table border=""0"" bordercolor=""yellow"" cellspacing=""1"" cellpadding=""3"">" & vbCrLf)
            Response.Write("                    <tr>" & vbCrLf)
            Response.Write("                              <td align=""left"" valign=""top"" class=""rptheader4"" colspan=""3"">Resources I'm Using</td>" & vbCrLf)
            Response.Write("                    </tr>" & vbCrLf)
            Response.Write("                    <tr class=""rpttableheader"">" & vbCrLf)
            Response.Write("                           <td valign=""bottom"" align=""center"">Name<nobr></td>" & vbCrLf)
            Response.Write("                           <td valign=""bottom"" align=""center"">Location<nobr></td>" & vbCrLf)
            Response.Write("                    </tr>" & vbCrLf)
                                                      strSQL = "sp_Get_Resources_IUse @CheckedOutByID=" & Session("EmployeeID")
                                                      Set Query = objConnection.Execute(strSQL)
                                                      If NOT Query.EOF Then
                                                            Do While NOT Query.EOF
                                                                  strRowclass = GetrowclassSM(i)
                                                                  i = i + 1
                                                                  ResourceID = Query("ResourceID")
            Response.Write("                      <tr>" & vbCrLf)
            Response.Write("                             <td align=""left"" valign=""top"" class=""" & strRowclass & """><A HREF=""/sss/main.asp?action=getharddesc&hid=" & Query("ResourceID") & """>" & Query("ResourceName") & "</a></td>" & vbCrLf)
            Response.Write("                             <td align=""left"" valign=""top"" class=""" & strRowclass & """>" & Query("LocationName") & "</td>" & vbCrLf)
            Response.Write("                      </tr>" & vbCrLf)
                                                                  Query.MoveNext
                                                            Loop
                                                      Else
            Response.Write("                      <tr>" & vbCrLf)
            Response.Write("                             <td align=""left"" valign=""top"" class=""" & strRowclass & """ colspan=""3"">no records found</td>" & vbCrLf)
            Response.Write("                      </tr>" & vbCrLf)
                                                      End If
            Response.Write("                  </table>" & vbCrLf)
            Response.Write("         </td>" & vbCrLf) '####Col3 End
      End If

            Response.Write("      <tr>" & vbCrLf)
            Response.Write("    </table>" & vbCrLf)
            Response.Write(" </td>" & vbCrLf)  '#### Main Column 1 End

End Sub



Sub ShowLastestAdded

      Dim strMonStartDate, strMonEndDate

      strMonStartDate = getFirstDayInMonth(date())
      strMonEndDate = getLastDayInMonth(date())

      strSQL = "sp_Get_EngineeringPCs_ThisMonth @StartDate='" & strMonStartDate & "', @EndDate='" & strMonEndDate & "'"

      Set Query = objConnection.Execute(strSQL)

      Response.Write("    <td align=""right"" valign=""top"">" & vbCrLf) '#### Main Column 2 Start
      Response.Write("       <table border=""0""  bordercolor=""blue""  cellspacing=""0"" cellpadding=""0"" name=""Data"">" & vbCrLf)
      Response.Write("         <tr>" & vbCrLf)
      Response.Write("            <td align=""right"" valign=""top"">" & vbCrLf)
      Response.Write("                      <table border=""0"" cellspacing=""1"" cellpadding=""3"">" & vbCrLf)
      Response.Write("                          <tr>" & vbCrLf)
      Response.Write("                                <td align=""left"" valign=""top"" class=""rptheader5"" colspan=""3"">Added This Month</td>" & vbCrLf)
      Response.Write("                          </tr>" & vbCrLf)
      Response.Write("                          <tr class=""rpttableheader"">" & vbCrLf)
      Response.Write("                                 <td valign=""bottom"" align=""center"">Name<nobr></td>" & vbCrLf)
      Response.Write("                                 <td valign=""bottom"" align=""center"">Location<nobr></td>" & vbCrLf)
'      Response.Write("                                 <td valign=""bottom"" align=""center"">Date<nobr></td>" & vbCrLf)
      Response.Write("                                 <td valign=""bottom"">Status<nobr></td>" & vbCrLf)
      Response.Write("                            </tr>" & vbCrLf)
                                                      If NOT Query.EOF Then
                                                              Do While NOT Query.EOF
                                                              strRowclass = GetrowclassSM(i)
                                                              i = i + 1
                                                             ResourceID = Query("ResourceID")
      Response.Write("                            <tr>" & vbCrLf)
      Response.Write("                                   <td align=""left"" valign=""top"" class=""" & strRowclass & """><A HREF=""/sss/hard_desc.asp?hid=" & Query("ResourceID") & """>" & Query("ResourceName") & "</a></td>" & vbCrLf)
      Response.Write("                                   <td align=""left"" valign=""top"" class=""" & strRowclass & """>" & Query("LocationName") & "</td>" & vbCrLf)
'      Response.Write("                                   <td align=""left"" valign=""top"" class=""" & strRowclass & """>" & FormatDateTime(Query("CreatedDate"), 2) & "</td>" & vbCrLf)
      Response.Write("                                   <td align=""center"" valign=""top"" class=""" & strRowclass & """>" & StatusColor(Session("EmployeeID"), ResourceID) & "</td>" & vbCrLf)
      Response.Write("                            </tr>" & vbCrLf)
                                                            Query.MoveNext
                                                            Loop
                                                      Else
      Response.Write("                            <tr>" & vbCrLf)
      Response.Write("                                   <td valign=""top"" class=""" & strRowclass & """ colspan=""3"">no records found</td>" & vbCrLf)
      Response.Write("                            </tr>" & vbCrLf)
                                                      End If

      Response.Write("                        </table>" & vbCrLf)

      Response.Write("            </td>" & vbCrLf)
      Response.Write("         <tr>" & vbCrLf)
      Response.Write("       </table>" & vbCrLf)
      Response.Write("    </td>" & vbCrLf) '#### Main Column 2 End
      Response.Write("</table>" & vbCrLf)

End sub


Sub AddResource

      Response.Write("    <td align=""right"" valign=""top"">" & vbCrLf) '#### Main Column 2 Start
      Response.Write("       <table border=""0""  bordercolor=""green""  cellspacing=""0"" cellpadding=""0"" name=""Data"">" & vbCrLf)
      Response.Write("         <tr>" & vbCrLf)
      Response.Write("            <td align=""left"" valign=""top"" class=""rptheader"">Add New Resource</td>" & vbCrLf)
      Response.Write("            </td>" & vbCrLf)
      Response.Write("         </tr>" & vbCrLf)
      Response.Write("         <tr>" & vbCrLf)
      Response.Write("            <td align=""right"" valign=""top"">" & vbCrLf)
      Response.Write("                        <form action=""/sss/main.asp?action=addresource"" method=""post"" name=""newresource"" OnSubmit=""return CheckNewResource();"">" & vbCrLf)
      Response.Write("                         <input type=""hidden"" name=""write"" value=""1"">" & vbCrLf)
      Response.Write("                          <table border=""0"" cellspacing=""0"" cellpadding=""3"">" & vbCrLf)
      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                      <td align=""right"" class=""required""><strong><a href=""/sss/sss_sss.asp?item=subject"" onClick=""popup('/sss/sss_sss.asp?item=subject'); return false;"">Name</a>:</strong></td>" & vbCrLf)
      Response.Write("                                      <td colspan=""4"" align=""left""><input type=""text""  name=""resourcename"" size=""20"" maxlength=""50"">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>" & vbCrLf)
      Response.Write("                                 </tr>" & vbCrLf)

      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                        <td align=""right"" valign=""middle"" width=""35%"" class=""required""><strong><a href=""/sss/sss_sss.asp?item=subject"" onClick=""popup('/sss/sss_sss.asp?item=Resourcetype'); return false;"">Resource Type</a></td>" & vbCrLf)
      Response.Write("                                      <td align=""left""  valign=""top""><select name=""resourcetype"">" & vbCrLf)
      Response.Write("                                            <option value="""">--Resource Type--</option>" & vbCrLf)
                                                                        strSQL = "sp_Get_Resource_Types"
                                                                        Set Query = objConnection.Execute(strSQL)
                                                                        If NOT Query.EOF Then
                                                                              Do While NOT Query.EOF
      Response.Write("                                            <option value=""" & Query("ResourceTypeID") & """")
                                                                                    Response.Write (">" & Query("ResourceType") & "</option>" & vbCrLf)
                                                                                    If Query.EOF Then Exit Do
                                                                                    Query.MoveNext
                                                                              Loop
                                                                              Else
      Response.Write("                                                <option value="""">No types found</option>" & vbCrLf)
                                                                        End If
                                                                                    Query.Close
                                                                                    Set Query=Nothing
      Response.Write("                                    </select></td>" & vbCrLf)
      Response.Write("                                </tr>" & vbCrLf)

      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                      <td align=""right"" class=""required"" valign=""middle""><strong><a href=""/sss/sss_sss.asp?item=subject"" onClick=""popup('/sss/sss_sss.asp?item=subject'); return false;"">Serial #</a>:</strong></td>" & vbCrLf)
      Response.Write("                                      <td colspan=""4"" align=""left""><input type=""text"" name=""serial"" size=""20"" maxlength=""50"">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>" & vbCrLf)
      Response.Write("                                 </tr>" & vbCrLf)
      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                        <td align=""right"" valign=""middle"" width=""35%"" class=""required""><strong><a href=""/sss/sss_sss.asp?item=location"" onClick=""popup('/sss/sss_sss.asp?item=location'); return false;"">Location</a></td>" & vbCrLf)
      Response.Write("                                      <td align=""left""  valign=""top""><select name=""location"" size=""1"">" & vbCrLf)
      Response.Write("                                            <option value="""">--Location--</option>" & vbCrLf)
                                                                        strSQL = "sp_Get_Location"
                                                                        Set Query = objConnection.Execute(strSQL)
                                                                        If NOT Query.EOF Then
                                                                              Do While NOT Query.EOF
      Response.Write("                                            <option value=""" & Query("LocationID") & """")
                                                                                    Response.Write (">" & Query("LocationName") & "</option>" & vbCrLf)
                                                                                    Query.MoveNext
                                                                              Loop
                                                                              Else
      Response.Write("                                                <option value="""">No Locations found</option>" & vbCrLf)
                                                                        End If
                                                                                    Query.Close
                                                                                    Set Query=Nothing
      Response.Write("                                    </select></td>" & vbCrLf)
      Response.Write("                                </tr>" & vbCrLf)

      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                        <td align=""right"" valign=""middle"" width=""35%"" class=""required""><strong><a href=""/sss/sss_sss.asp?item=subject"" onClick=""popup('/sss/sss_sss.asp?item=OS'); return false;"">OS</a></td>" & vbCrLf)
      Response.Write("                                      <td align=""left""  valign=""top""><select name=""os"" size=""1"">" & vbCrLf)
      Response.Write("                                            <option value="""">--OS--</option>" & vbCrLf)
                                                                        strSQL = "sp_Get_OS"
                                                                        Set Query = objConnection.Execute(strSQL)
                                                                        If NOT Query.EOF Then
                                                                              Do While NOT Query.EOF
      Response.Write("                                            <option value=""" & Query("OSID") & """")
                                                                                    Response.Write (">" & Query("OSName") & "</option>" & vbCrLf)
                                                                                    Query.MoveNext
                                                                              Loop
                                                                              Else
      Response.Write("                                                <option value="""">No types found</option>" & vbCrLf)
                                                                        End If
                                                                                    Query.Close
                                                                                    Set Query=Nothing
      Response.Write("                                    </select></td>" & vbCrLf)
      Response.Write("                                </tr>" & vbCrLf)

      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                        <td align=""right"" valign=""top"" width=""35%"" class=""required""><strong><a href=""/sss/sss_sss.asp?item=subject"" onClick=""popup('/sss/sss_sss.asp?item=brand'); return false;"">Brand</a></td>" & vbCrLf)
      Response.Write("                                      <td align=""left""  valign=""top""><select name=""brand"" size=""1"">" & vbCrLf)
      Response.Write("                                            <option value="""">--Brand--</option>" & vbCrLf)
                                                                        strSQL = "sp_Get_Brand"
                                                                        Set Query = objConnection.Execute(strSQL)
                                                                        If NOT Query.EOF Then
                                                                              Do While NOT Query.EOF
      Response.Write("                                            <option value=""" & Query("BrandID") & """")
                                                                                    Response.Write (">" & Query("BrandName") & "</option>" & vbCrLf)
                                                                                    Query.MoveNext
                                                                              Loop
                                                                              Else
      Response.Write("                                                <option value="""">No Brands found</option>" & vbCrLf)
                                                                        End If
                                                                                    Query.Close
                                                                                    Set Query=Nothing
      Response.Write("                                    </select></td>" & vbCrLf)
      Response.Write("                                </tr>" & vbCrLf)

      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                        <td align=""right"" valign=""top"" width=""35%"" class=""required""><strong><a href=""/sss/sss_sss.asp?item=subject"" onClick=""popup('/sss/sss_sss.asp?item=cputype'); return false;"">CPU Type</a></td>" & vbCrLf)
      Response.Write("                                      <td align=""left""  valign=""top""><select name=""cputype"" size=""1"">" & vbCrLf)
      Response.Write("                                            <option value="""">--CPU--</option>" & vbCrLf)
                                                                        strSQL = "sp_Get_CPUType"
                                                                        Set Query = objConnection.Execute(strSQL)
                                                                        If NOT Query.EOF Then
                                                                              Do While NOT Query.EOF
      Response.Write("                                            <option value=""" & Query("CPUTypeID") & """")
                                                                                    Response.Write (">" & Query("CPUType") & "</option>" & vbCrLf)
                                                                                    Query.MoveNext
                                                                              Loop
                                                                              Else
      Response.Write("                                                <option value="""">No Types found</option>" & vbCrLf)
                                                                        End If
                                                                                    Query.Close
                                                                                    Set Query=Nothing
      Response.Write("                                    </select></td>" & vbCrLf)
      Response.Write("                                </tr>" & vbCrLf)

      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                        <td align=""right"" valign=""top"" width=""35%"" class=""required""><strong><a href=""/sss/sss_sss.asp?item=cpuspeed"" onClick=""popup('/sss/sss_sss.asp?item=cpuspeed'); return false;"">CPU Speed</a></td>" & vbCrLf)
      Response.Write("                                      <td align=""left""  valign=""top""><select name=""cpuspeed"" size=""1"">" & vbCrLf)
      Response.Write("                                            <option value="""">--CPU Speed--</option>" & vbCrLf)
                                                                        strSQL = "sp_Get_CPUSpeed"
                                                                        Set Query = objConnection.Execute(strSQL)
                                                                        If NOT Query.EOF Then
                                                                              Do While NOT Query.EOF
      Response.Write("                                            <option value=""" & Query("CPUSpeedID") & """")
                                                                                    Response.Write (">" & Query("SpeedValue") & "</option>" & vbCrLf)
                                                                                    Query.MoveNext
                                                                              Loop
                                                                              Else
      Response.Write("                                                <option value="""">No Speeds found</option>" & vbCrLf)
                                                                        End If
                                                                                    Query.Close
                                                                                    Set Query=Nothing
      Response.Write("                                    </select></td>" & vbCrLf)
      Response.Write("                                </tr>" & vbCrLf)

      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                        <td align=""right"" valign=""top"" width=""35%"" class=""required""><strong><a href=""/sss/sss_sss.asp?item=ramamount"" onClick=""popup('/sss/sss_sss.asp?item=ramamount'); return false;"">Disk Space</a></td>" & vbCrLf)
      Response.Write("                                      <td align=""left""  valign=""top""><select name=""hdsize"" size=""1"">" & vbCrLf)
      Response.Write("                                            <option value="""">--Space (total all drives)--</option>" & vbCrLf)
                                                                        strSQL = "sp_Get_DiskSize"
                                                                        Set Query = objConnection.Execute(strSQL)
                                                                        If NOT Query.EOF Then
                                                                              Do While NOT Query.EOF
      Response.Write("                                            <option value=""" & Query("DiskSizeID") & """")
                                                                                    Response.Write (">" & Query("DiskSize") & "</option>" & vbCrLf)
                                                                                    Query.MoveNext
                                                                              Loop
                                                                              Else
      Response.Write("                                                <option value="""">No Sizes found</option>" & vbCrLf)
                                                                        End If
                                                                                    Query.Close
                                                                                    Set Query=Nothing
      Response.Write("                                    </select></td>" & vbCrLf)
      Response.Write("                                </tr>" & vbCrLf)

      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                        <td align=""right"" valign=""top"" width=""35%"" class=""required""><strong><a href=""/sss/sss_sss.asp?item=ramamount"" onClick=""popup('/sss/sss_sss.asp?item=ramamount'); return false;"">RAM</a></td>" & vbCrLf)
      Response.Write("                                      <td align=""left""  valign=""top""><select name=""ramamount"" size=""1"">" & vbCrLf)
      Response.Write("                                            <option value="""">--RAM Amount--</option>" & vbCrLf)
                                                                        strSQL = "sp_Get_RAMAmount"
                                                                        Set Query = objConnection.Execute(strSQL)
                                                                        If NOT Query.EOF Then
                                                                              Do While NOT Query.EOF
      Response.Write("                                            <option value=""" & Query("RAMAmountID") & """")
                                                                                    Response.Write (">" & Query("RAMAmount") & "</option>" & vbCrLf)
                                                                                    Query.MoveNext
                                                                              Loop
                                                                              Else
      Response.Write("                                                <option value="""">No Amounts found</option>" & vbCrLf)
                                                                        End If
                                                                                    Query.Close
                                                                                    Set Query=Nothing
      Response.Write("                                    </select></td>" & vbCrLf)
      Response.Write("                                </tr>" & vbCrLf)

      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                        <td align=""right"" valign=""top"" width=""35%"" class=""required""><strong><a href=""/sss/sss_sss.asp?item=subject"" onClick=""popup('/sss/sss_sss.asp?item=softwareinstalled'); return false;"">Software<br>Installed</a></td>" & vbCrLf)
      Response.Write("                                      <td align=""left""  valign=""top""><select name=""software"" size=""10"" multiple>" & vbCrLf)
      Response.Write("                                            <option value=""""></option>" & vbCrLf)
                                                                        strSQL = "sp_Get_Software"
                                                                        Set Query = objConnection.Execute(strSQL)
                                                                        If NOT Query.EOF Then
                                                                              Do While NOT Query.EOF
      Response.Write("                                            <option value=""" & Query("SoftwareID") & """")
                                                                                    Response.Write (">" & Query("SoftwareName") & "</option>" & vbCrLf)
                                                                                    Query.MoveNext
                                                                              Loop
                                                                              Else
      Response.Write("                                                <option value="""">No Names found</option>" & vbCrLf)
                                                                        End If
                                                                                    Query.Close
                                                                                    Set Query=Nothing
      Response.Write("                                    </select></td>" & vbCrLf)
      Response.Write("                                </tr>" & vbCrLf)
      Response.Write("                                 <tr>" & vbCrLf)
      Response.Write("                                      <td></td>" & vbCrLf)
      Response.Write("                                      <td colspan=""4""><input type=""submit"" name=""Submit"" value=""Add"" class=""submitbutton""> &nbsp;<input type=""button"" name=""cancel"" value=""Cancel"" class=""submit_cancel"" OnClick=""window.open('/sss/main.asp?status=rc', '_self')""></td>" & vbCrLf)
      Response.Write("                                 </tr>" & vbCrLf)
      Response.Write("                                 <tr><td colspan=""6""><p class=""font-one"" align=""center""><span class=""required"">Fields listed in dark red are required.</span><td><tr>" & vbCrLf)
      Response.Write("                       </table>" & vbCrLf)
      Response.Write("                       </form>" & vbCrLf)
      Response.Write("          </table>" & vbCrLf)
      Response.Write("    </td>" & vbCrLf) '#### Main Column 2 End
      Response.Write("   </tr>" & vbCrLf)
      Response.Write("</table>" & vbCrLf)


End Sub




Sub SubmitResource

      Dim strCreateDate, intCreatedByID, intLocationID, intResourceTypeID, strResourceName, intCPUTypeID, intCPUSpeedID, intBrandID, intRAMAmountID, intOSID, strSerialNum, intDiskSizeID, intNewResourceID, intOwnerID

      strCreateDate = Now()
      intOwnerId = Session("EmployeeID")
      intCreatedByID = Session("EmployeeID")
      intLocationID = Request("location")
      intDiskSizeID = Request("hdsize")
      intResourceTypeID      = Request("resourcetype")
      strResourceName = Trim(Request("resourcename"))
      intCPUTypeID = Request("cputype")
      intCPUSpeedID = Request("cpuspeed")
      intBrandID = Request("brand")
      intRAMAmountID = Request("ramamount")
      intOSID = Request("os")
      strSerialNum = Trim(Request("serial"))

      If CheckForBlankValues(intOwnerId & "|||" & intCreatedByID & "|||" & intLocationID & "|||" & intDiskSizeID & "|||" & intResourceTypeID & "|||" & strResourceName & "|||" & intCPUTypeID & "|||" & intCPUSpeedID & "|||" & intBrandID & "|||" & intRAMAmountID & "|||" & intOSID & "|||" & strSerialNum) Then

            strSQL = "sp_Add_Resource"
            strSQL = strSQL & " @OwnerID  = '" & Cint(intOwnerID) & "',"
            strSQL = strSQL & " @CreatedByID  = '" & Cint(intCreatedByID) & "',"
            strSQL = strSQL & " @LocationID = '" & Cint(intLocationID)  & "',"
            strSQL = strSQL & " @ResourceTypeID = '" & Cint(intResourceTypeID)  & "',"
            strSQL = strSQL & " @ResourceName = '" & strResourceName & "',"
            strSQL = strSQL & " @DiskSizeID = '" & Cint(intDiskSizeID)  & "',"
            strSQL = strSQL & " @CPUTypeID = '" & Cint(intCPUTypeID) & "',"
            strSQL = strSQL & " @CPUSpeedID = '" & Cint(intCPUSpeedID)  & "',"
            strSQL = strSQL & " @BrandID = '" & Cint(intBrandID) & "',"
            strSQL = strSQL & " @RAMAmountID = '" & Cint(intRAMAmountID) & "',"
            strSQL = strSQL & " @SerialNumber = '" & strSerialNum  & "',"
            strSQL = strSQL & " @CreatedDate = '" & strCreateDate & "',"
            strSQL = strSQL & " @OSID = '" & intOSID & "'"

            Set Query = objConnection.Execute(strSQL)

            Session("LastResourceID") = Query("NewResourceID")

            intNewResourceID = Session("LastResourceID")

            Set Query = Nothing

            if len(trim(request("software")))>0 then
              Dim strMySelectValue, arrSoftwareList
              strMySelectValue = request("software")
              arrSoftwareList = split(strMySelectValue, ",")
              for i=0 to ubound(arrSoftwareList)
                        strSQL = "sp_Add_Software @SoftwareID=" & arrSoftwareList(i) & ", @NewResourceID=" & intNewResourceID
                        Set Query = objConnection.Execute(strSQL)
              next
            end if

            Response.Redirect ("/sss/main.asp")
      Else
            Response.Write("<p class=""error"">Error -- All Required Fields Not Completed</p><p>Please use your back button to return to the form and complete all required fields.</p>" & vbCrLf)
      End If


%>
<script type="text/javascript">
<!--

var f = document.newresource;

function CheckNewResource() {

      if (f.resourcename.value.length < 5) {
            alert("Please enter a valid Resource Name");
            f.resourcename.focus();
            return false;
      } else if (f.resourcetype.options[f.resourcetype.selectedIndex].value.length < 1) {
            alert("Please select the type of Resource Type");
            f.resourcetype.focus();
            return false;
      } else if (f.serial.value.length < 5) {
            alert("Please enter a valid Serial #");
            f.serial.focus();
            return false;
      } else if (f.location.options[f.location.selectedIndex].value.length < 1) {
            alert("Please select the Location of the Resource");
            f.location.focus();
            return false;
      } else if (f.os.options[f.os.selectedIndex].value.length < 1) {
            alert("Please select the OS of the Resource");
            f.os.focus();
            return false;
      } else if (f.brand.options[f.brand.selectedIndex].value.length < 1) {
            alert("Please select the Brand of the Resource");
            f.brand.focus();
            return false;
      } else if (f.cputype.options[f.cputype.selectedIndex].value.length < 1) {
            alert("Please select the CPU Type of the Resource");
            f.cputype.focus();
            return false;
      } else if (f.cpuspeed.options[f.cpuspeed.selectedIndex].value.length < 1) {
            alert("Please select the CPU Speed of the Resource");
            f.cpuspeed.focus();
            return false;
      } else if (f.hdsize.options[f.hdsize.selectedIndex].value.length < 1) {
            alert("Please select the Hard Drive Size (in Gigibytes) of the Resource");
            f.hdsize.focus();
            return false;
      } else if (f.ramamount.options[f.ramamount.selectedIndex].value.length < 1) {
            alert("Please select the RAM Amount of the Resource");
            f.ramamount.focus();
            return false;
      } else if (f.software.options[f.software.selectedIndex].value.length < 1) {
            alert("Please select any installed Software");
            f.software.focus();
            return false;
      }

      // Prevent multiple form submissions
      f.Submit.value = "Resource Submitted, Please Wait...";
      f.Submit.disabled = true;
      return true;
}
// -->
</script>
<%

End Sub


%>
<!--#include virtual="/sss/hard_desc.asp" -->

<!--#include virtual="/sss/includes/footer.asp" -->

0
 
ap_sajithCommented:
Ok.. Thre seems nothing wrong with the code snippets...

Could you post the out put html (abridged version would be nice.. :))....) so that i can try executing it from my side.

As for organising your code, you have it nicely organised in subroutines and functions... However, i personally dont like the HTML content being rendered using all these response.writes. Another option is to use a string concatenation class and create a output string and then do a single response.write. Refer http://www.15seconds.com/howto/pg000929.htm for more info on how to use a string concatenation class.

I personally think that the way you have coded still makes maintenance a bit difficult and any new development more time consuming. Also, instead of calling response.write in each line, you could use a custom subroutine that is much easier to call.

eg:
Sub Writeout (ByVal sOutput)
Response.write (sOutput)
End Sub

Cheers!!


0
 
ap_sajithCommented:
sorry.. Refer this article on how to use a string concatenation class..
http://www.eggheadcafe.com/articles/20011227.asp

Cheers!!
0
 
fritz_the_blankCommented:
If you could post a link to the page, we could square this away in short order.

FtB
0
 
fritz_the_blankCommented:
If you can't post an external link to the page, then please do the following:

1) Open the page in Netscape
2) Type the following into the address bar:

javascript:

3) Now a debugging console will apprear with the exact line and description of the error.

FtB
0
 
dba123Author Commented:
>>>However, i personally dont like the HTML content being rendered using all these response.writes

Yea, when I came to this company, I didn't either.  But as time went on, I wanted to keep to the standard and wanted to reuse a lot of code that was already there.  Rather then have to re-engineer the code back to separating HTML and ASP, I stuck with using Response.Write and am now very used to it and really don't even know they are there when I try to troubleshoot my code.  And as everyone knows, Microsoft recommends doing it this way, however little or big the performance gain is...I'd prefer to stick to it now that I'm used to it.

>>>I personally think that the way you have coded still makes maintenance a bit difficult and any new development more time consuming. Also, instead of calling response.write in each line, you could use a custom subroutine that is much easier to call.

So do you mean difficult due to the Response.Writes?  Also, it seems to me more complex to create classes and complex functions to spit out strings....anyway - thanks for your comments, they are appreciated.


0
 
dba123Author Commented:
great, I came in this morning, rebooted, logged back in and now I don't even get the error in IE.  I am trying to get it to show again but can't.  Also, I notice that when I submit my form, the function isn't being called or else I should at least get prompts telling me that my fields are blank....I don't even get that.  I changed no code from the last post from last night that you looked at.
0
 
dba123Author Commented:
Looks like my SubmitResouce Sub is being run but that's it after I submit....it is bypassing the JavaScript function now
0
 
dba123Author Commented:
The only think I can think of is that I was remoting in via Terminal Services last night and using my PC here as the desktop I was working on.
0
 
dba123Author Commented:
Here's a question.  I am watching the left corner of IE.  For a split second, I see that there is a JavaScript Error (yellow exclamation).  Is there any way to freeze the page so I can get to that error?  I can't get to it because it passes by so fast.
0
 
fritz_the_blankCommented:
Perhaps you were viewing a cached version earlier and now you are seeing an updated version?

FtB
0
 
dba123Author Commented:
What Risk do I run installing Netscape...I'm afraid of messing up my IE / Opra Environment
0
 
fritz_the_blankCommented:
None at all. I keep NS on my machine solely for troubleshooting JavaScript problems and for making sure that my CSS looks okay.

FtB
0
 
dba123Author Commented:
>>Perhaps you were viewing a cached version earlier and now you are seeing an updated version?
must be.

what about it not calling the function at all...or so it seems?  I put an alert in the very beginning of the function, before all the Ifs, and I get no alert with the form is submitted.
0
 
dba123Author Commented:
>>>None at all. I keep NS on my machine solely for troubleshooting JavaScript problems and for making sure that my CSS looks okay
good idea.  We code for IE and really don't care about Netscape (our environment soley depends on IE since all our users use it) but it would be good to use it for JavaScript issues at least for me.
0
 
fritz_the_blankCommented:
Okay, we have to get back to some kind of a focus--this question is going everywhere!!!

Take a few minutes to assess where you are at, and then let's regroup.

FtB
0
 
dba123Author Commented:
We do practice a bit of cross browser stuff but not much...and usually use Opra to compare stuff but Opra isn't producing any errors anymore either...which is weird cause Opra's cache is usually pretty accurate and clears out ok.
0
 
dba123Author Commented:
that's where I'm at...the function doesn't appear to be called.
0
 
dba123Author Commented:
The code is completely the same, nothing has changed except I woke up tihs morning to find that nothing happens on submit now (function isn't called)
0
 
fritz_the_blankCommented:
So you are saying that when you submit the form, nothing is happening, is that correct? Are there any errors indicated on your status bar?

FtB
0
 
fritz_the_blankCommented:
Also, is there no way that you can give me a link to this page?

FtB
0
 
dba123Author Commented:
>>>So you are saying that when you submit the form, nothing is happening, is that correct? Are there any errors indicated on your status bar?
The form submits, meaning it calls SubmitResource...just that the JavaScript function is what is not doing anything. I put an alert in it just to see if it got there and it doesn't.

>>>Also, is there no way that you can give me a link to this page?
I know this must be frustrating by now but...no, it is our Intranet.
0
 
fritz_the_blankCommented:
Okay, run the page in your browser, choose view source, and then paste the result here.

FtB
0
 
dba123Author Commented:
it's a hell of a lot of code to paste in here.
0
 
dba123Author Commented:
I'm putting a link to the code from my yahoo briefcase..hold on.
0
 
dba123Author Commented:
0
 
fritz_the_blankCommented:
Okay, there is no javascript code, so none of the JavaScript functions are defined, hence the error.

FtB
0
 
dba123Author Commented:
ok, so is it where I placed my JavaScript then?  I ended the asp portion in my sub and then included the JavaScript then ended my sub...what am I doing wrong here?
0
 
fritz_the_blankCommented:
Put all of your JavaScript between the head tags.

FtB
0
 
dba123Author Commented:
Ok, I moved the JavaScript out of my Sub and just at the end of my ASP file.  Works now. But I've seen this done before, exactly like that where y ou include JavaScript as part of your ASP function that is called but just exit out the ASP sub in the middle of it to add the JavaScript, then close your sub for ASp at the end by reopening <% the ASP and add your End Sub.

Not sure why it didn't work for me.
0
 
fritz_the_blankCommented:
I don't know why either--I suppose that we could figure this out if I could look over your shoulder and test every step of the way. Why not just dump all of your JavaScript code into one big include file, let's say Scripts.js and then include that file in your page header like this:

<script language="JavaScript" src="Scripts.js"></script>


FtB
0
 
dba123Author Commented:
If I put all of it between the head tags, then that's what I have a functions include for.  The functions Include is actually included in my main.asp before the header.  So why does it make a difference.  All our pages don't necessarily have it in  the <head> tag and it has never been a problem.  OUr pages include so many includes, etc. and because we use and includes file, I don't see why the includeds function file is working just fine but when I insert it into my asp page it wasn't.  We have quite a few other applications on our Intranet that embeds JavaScript everywhere and the person before me has no problem.
0
 
fritz_the_blankCommented:
I would have to see everything to know. However, problems often result from an include referencing an include. You are better off having a bunch of dfferent files and then using a separate include line for each.

FtB
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 35
  • 12
  • 5
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now