VBScript - Cannot specify the document or form.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dino123
    New Member
    • Feb 2007
    • 7

    VBScript - Cannot specify the document or form.

    Hi

    I have a page written in VBScript, which uses values from a page posted to it, to send an e-mail. The problem is that when I try to specify a control within the page I get an error, saying "Object Required : Document". Here is a piece of the code:

    Code:
    <%@ Language=VBScript %>
    <%
    Dim szMail
    
    szMail =	"<form id= SendAccounting  name = SendAccounting language=VBScript>"&_
    			"<table>"&_
    				"<TR>"&_
    				"<TD><STRONG><FONT size = 6; color = #ff3366;>"&"Accounting Instruction"&"</FONT></STRONG>"&_
    				"</TD>"&_
    				"</TR>"&_
    				"<TR>"&_
    				"</TR>"&_
    			"</table>"&_
      
    
    				"<TABLE>" &_
    					"<TR>"&_
    							"<STRONG><FONT color = #ff6666;>" & "Please mark one of the following:" & "</FONT> </STRONG>" &_	
    					"</TR>"&_
    					"<TR>"&_
    						"<TD><STRONG>"& "Matching Instruction:" & "</STRONG><INPUT id= chkMatching type= checkbox name= chkMatching>&nbsp;&nbsp;&nbsp;&nbsp;</TD>"&_ 
    						"<TD><STRONG>"& "Journal:"&"</STRONG></STRONG><INPUT id= chkJournal type= checkbox name= chkJournal>&nbsp;&nbsp;&nbsp;&nbsp;</TD>"&_ 
    						"<TD><STRONG>"& "Write Off:"&"</STRONG></STRONG><INPUT id= chkWriteOff type= checkbox name= chkWriteOff>&nbsp;&nbsp;&nbsp;&nbsp;</TD>"&_ 
    					"</TR>"&_
    					"<TR>"&_
    					"</TR>"&_
    					"<TR>"&_
    					"</TR>"&_
    				"</TABLE>"&_
    "</form>"
    
    Dim TheForm
    Set TheForm = document.SendAccounting
    
    if request.Form("chkMatching")= "on" then
    SendAccounting.chkMatching1.checked
    end if
    The problem occures when I try to reference the control by specifying the document and form that the controls in.

    I have also tried Document.forms( o).chkmatching1 , but that doesn'y work either, I get the same error.

    Any help will be appreciated.

    Thanks
  • dorinbogdan
    Recognized Expert Contributor
    • Feb 2007
    • 839

    #2
    try to give an ID to the checkbox (i.e. chkID1) and use
    [HTML]document.getEle mentById("chkID 1")[/HTML] to get a reference to it.

    Comment

    • Dino123
      New Member
      • Feb 2007
      • 7

      #3
      Hi

      I tried that, though I'm still getting the "Object required: 'document' " error.

      Thanks

      Comment

      • dorinbogdan
        Recognized Expert Contributor
        • Feb 2007
        • 839

        #4
        Hmm, it seems to me that you dont have any document there, just the szMail string with the HTML code, but it is not used anywere?

        Comment

        • Dino123
          New Member
          • Feb 2007
          • 7

          #5
          Yup. As you see I'm dynamically building up the table using script within the "", I've given the form the id, any ideas on the document part of it?

          Would you like me to post all the code it's about 400 lines long? I only posted the offending bit.

          Comment

          • dorinbogdan
            Recognized Expert Contributor
            • Feb 2007
            • 839

            #6
            Question:
            Do you can access the form through
            [HTML]document.getEle mentById("SendA ccounting")[/HTML]
            ?

            Comment

            • Dino123
              New Member
              • Feb 2007
              • 7

              #7
              Hi

              Tried that as well, still no luck. Getting the same error message.

              Thanks

              Comment

              • dorinbogdan
                Recognized Expert Contributor
                • Feb 2007
                • 839

                #8
                You should be able to access the chkMatching checkbox using
                <%Request.Form( "chkMatching")% >

                but I'm not sure if you can change its checked state from server on this way.

                Comment

                • Dino123
                  New Member
                  • Feb 2007
                  • 7

                  #9
                  Ok. I'l give it a go, though the checkbox control is on the same form.

                  Comment

                  • dorinbogdan
                    Recognized Expert Contributor
                    • Feb 2007
                    • 839

                    #10
                    If want to update some controls on client-side, try to use AJAX.
                    See this small tutorial.

                    Comment

                    • Dino123
                      New Member
                      • Feb 2007
                      • 7

                      #11
                      Ok. I'll give it a go, let u know if it works

                      Comment

                      Working...