Solved

VBSCRIPT ERROR: Object doesn't support property or method

Posted on 2004-09-07
15
674 Views
Last Modified: 2010-08-05
Hi.

I have a FORM with hidden elements and after the submitting the form, a VBScript routine is called that will assign values to the other hidden elements of the same form and submit those elements to another ASP page.

Problem is I get an error message that says: "Object doesn't support this property or method: document.form1 " which points to my VBScript statement: document.form1.hidVal = intVar

Thanks for any help I could get!
0
Comment
Question by:winayf
  • 4
  • 2
  • 2
  • +5
15 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 11995750
try

document.form1.hidVal.value=intVar

or

document.forms(0).hidVal.value=intVar
0
 
LVL 19

Expert Comment

by:webwoman
ID: 11999457
What's the rest of the code? Is this client side vbscript? Because you're not going to be able to manipulate the form elements with SERVER side vbscript if you're basing the interaction on user input.
0
 

Author Comment

by:winayf
ID: 12002263
yes..it is client-side vbscript which was executed after a form has been submitted.
i wanted the same form to be submitted to another ASP page but i cannot assign values to form elements.

<% if Request.Form('transaction').Item = "ok" {%>

<SCRIPT Language=VBScript>
  document.form1.hidValFile.value = xFiles
  document.form1.hidValWrite.value = intWrite
  document.form1.hidValDup.value = intDup
  document.form1.hidExt.value = intExt
  document.form1.action = "myASP2.asp"
  document.form1.submit()
</SCRIPT>

<%}%>


my form has this:

<FORM METHOD="post" NAME="form1" ACTION="myASP.asp">
   <INPUT type="button" style="width:55px" value="Scan" class=button id=btnScan name=btnScan onclick="form1.transaction.value = 'ok'; form1.submit();">  
   <INPUT type="button" style="width:55px" value="Clear" class=button id=btnClear name=btnClear>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   <INPUT type="hidden" style="WIDTH: 55px" value="<%=Request.Form("hidProject")%>" id="hidProject" name="hidProject">
   <INPUT type="hidden" style="WIDTH: 55px" value="<%=Request.Form("hidTrans")%>" id="hidTrans" name="hidTrans">  
   <INPUT type="hidden" style="WIDTH: 55px" value="<%=Request.Form("hidJob")%>" id="hidJob" name="hidJob">
   <INPUT type="hidden" style="WIDTH: 55px" value="<%=Request.Form("hidCD")%>" id="hidCD" name="hidCD">
   <INPUT type="hidden" style="WIDTH: 55px" value="<%=Request.Form("hidPath")%>" id="hidPath" name="hidPath">        
   <INPUT type="hidden" style="WIDTH: 55px" value="<%=Request.Form("hidActivity")%>" id="hidActivity" name="hidActivity">
   <INPUT type="hidden" style="WIDTH: 55px" value="<%=Request.Form("hidValFile")%>" id="hidNumRec" name="hidNumRec">
   <INPUT type="hidden" style="WIDTH: 55px" value="<%=Request.Form("hidValWrite")%>" id="hidRecWritten" name="hidRecWritten">
   <INPUT type="hidden" style="WIDTH: 55px" value="<%=Request.Form("hidValDup")%>" id="hidDupRec" name="hidDupRec">
   <INPUT type="hidden" style="WIDTH: 55px" value="<%=Request.Form("hidExt")%>" id="hidInvExt" name="hidInvExt">  
</FORM>
0
 

Author Comment

by:winayf
ID: 12002302
sorry YZlat..

i forgot to include the ".value" when i wrote the question. :) good eye you have there!
my script has .value in it but still, it's not working! :(
0
 

Author Comment

by:winayf
ID: 12002476
oopps...typo error:

my form looks like this:

<FORM METHOD="post" NAME="form1" ACTION="myASP.asp">
   <INPUT type="button" style="width:55px" value="Scan" class=button id=btnScan name=btnScan onclick="form1.transaction.value = 'ok'; form1.submit();">  
   <INPUT type="button" style="width:55px" value="Clear" class=button id=btnClear name=btnClear>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   <INPUT type="hidden" style="WIDTH: 55px" value="<%=Request.Form("hidProject")%>" id="hidProject" name="hidProject">
   <INPUT type="hidden" style="WIDTH: 55px" value="<%=Request.Form("hidTrans")%>" id="hidTrans" name="hidTrans">  
   <INPUT type="hidden" style="WIDTH: 55px" value="<%=Request.Form("hidJob")%>" id="hidJob" name="hidJob">
   <INPUT type="hidden" style="WIDTH: 55px" value="<%=Request.Form("hidCD")%>" id="hidCD" name="hidCD">
   <INPUT type="hidden" style="WIDTH: 55px" value="<%=Request.Form("hidPath")%>" id="hidPath" name="hidPath">        
   <INPUT type="hidden" style="WIDTH: 55px" value="<%=Request.Form("hidActivity")%>" id="hidActivity" name="hidActivity">
   <INPUT type="hidden" style="WIDTH: 55px" value="<%=Request.Form("hidValFile")%>" id="hidValFile" name="hidValFile">
   <INPUT type="hidden" style="WIDTH: 55px" value="<%=Request.Form("hidValWrite")%>" id="hidValWrite" name="hidValWrite">
   <INPUT type="hidden" style="WIDTH: 55px" value="<%=Request.Form("hidValDup")%>" id="hidValDup" name="hidValDup">
   <INPUT type="hidden" style="WIDTH: 55px" value="<%=Request.Form("hidExt")%>" id="hidExt" name="hidExt">  
</FORM>

there...sorry for the typo error
0
 
LVL 1

Expert Comment

by:mlpk_tyr
ID: 12003948
hi,

problem lies actually in the onclick method call. try replacing the statemnets as follows,

first,
there is no such element called transaction in your current form, have u missed it or  want to use a different element. replace with an existing element

second,
there may be more than one forms in the current scope submit my form  name as follows,

onclick="document.forms['form1'].transaction.value = 'ok'; document.forms['form1'].submit();"

hope this work,
mlpk_tyr
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:winayf
ID: 12004689
hi mlpk_tyr..

i rechecked my code and there is a hidden transaction element (which i might have deleted when i was editing the above entries) and only 1 form in the ASP page.

what i am doing is on the 1st submission of the form, a client side vbscript routine will be executed if the transaction element equates to "ok"..on the latter part of the vbscript routine, i am trying to assign values to the other hidden elements of the same form and submit the same form to another ASP page..but my browser gets the "object doesn't support property or method" error..

i've been examining my forms and i can see that my elements are all present..i don't what is wrong!

thanks for every single help all of you are extending!!!! :) :)
0
 
LVL 19

Expert Comment

by:webwoman
ID: 12022912
Normally things like that are done in client side JAVASCRIPT, not vbscript. It's very possible vbscript may not even do what you need.

If you want to submit the form again, it would be much easier to just rewrite what you have so that it only needs to submit ONCE.

It looks like you're mixing client side and server side vbscript -- you CANNOT use request.form without SUBMITTING the form to THAT PAGE, and running it ON THE SERVER. That's server side code, not client side.
0
 

Expert Comment

by:YAST_AngelRipper
ID: 12074019
Are you aware that client-side VBScript is only executable on Internet Explorer ?

No other Browser will know what you want him to do...

I agree with webwoman, use Java Script for clientside scripting,
and to be on the safe side avoid using clientside as much as you can,
because you never know if it is'nt blocked by security settings.

And one more thing:

If your have a hidden field in your form to find out with request.form on the server side
if the form had already been posted, you do not need to set the value in the field dynamically
before submitting, just write it static in the value property of the field.

The first time your site is called there is no request.form because nothing has been submitted,
so it does not matter if there is a value in the field or not.
When the form is submitted and you ALWAYS set the value then it is the same as if it was already there all the time.

And if you want to check first if the form data has been entered correctly check it on the server side,
it's safer and you can react proberly on everything (nice error outputs etc)
if someone has cancelled clientside scripting it maybe won't be validated at all and then maybe cause an
ugly server side error
0
 

Expert Comment

by:evolutional
ID: 12199792
I'd be more akin to hook the OnSubmit event of the form than the OnClick event of the button. As the event is triggered before the form is actually submitted, you can halt the submission too (by returning False) if you need to.
0
 
LVL 1

Expert Comment

by:marc-pm
ID: 12284275
Hi,

I would rather ask WHERE is that script of yours ? Remember that script is executed on-line as it is readed in from the file - not after all page has been loaded. So what may hapen is that not all form elements (or even form itself) may not yet exists.

In addition, using VBScript in client side is bad choice - use JavaScript/JScript instead. Though there are some differences in JavaScript and JScript they are almost the same - at least in basics - and are supported by all modern browsers.

And to perform 2 tasks for 1 submit - I would rather suggest that you use ASP Server.Execute("myASP2.asp") for that purpose. You can call it if the actions in the first asp where successful and skip it otherwise. The myASP2.asp would receive all request information and all of it's output will be returned to the calling script.

M.
0
 

Expert Comment

by:evolutional
ID: 12553298
I'm assuming the author solved the problem himself, perhaps?
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12624011
PAQed with points refunded (125)

modulo
Community Support Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now