Link to home
Start Free TrialLog in
Avatar of winayf
winayf

asked on

VBSCRIPT ERROR: Object doesn't support property or method

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!
Avatar of YZlat
YZlat
Flag of United States of America image

try

document.form1.hidVal.value=intVar

or

document.forms(0).hidVal.value=intVar
Avatar of webwoman
webwoman

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.
Avatar of winayf

ASKER

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>
Avatar of winayf

ASKER

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! :(
Avatar of winayf

ASKER

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
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
Avatar of winayf

ASKER

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!!!! :) :)
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.
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
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.
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.
I'm assuming the author solved the problem himself, perhaps?
ASKER CERTIFIED SOLUTION
Avatar of modulo
modulo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial