Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - getElemetById doesn't work in VBscipt

Reply
 
Old 11-10-2008   #1 (permalink)
jtz


 
 

getElemetById doesn't work in VBscipt

I'm writing code in VBscript for a web project and I find the getElementById
method
seems doesn't work in VBscipt.the code "set obj=eval('input1')" work,but
when the code is "set obj=document.getElement ById('input1')",I get "nothing"
by "msgbox typeName(obj)".what is the matter?
jtz

My System SpecsSystem Spec
Old 11-10-2008   #2 (permalink)
Tim Williams


 
 

Re: getElemetById doesn't work in VBscipt

Your sample code has a typo (space) in "getElement ById".
And vbscript uses double-quotes for string literals...

If you didn't paste that, then show your actual code and the html fragment
defining "input1"

Tim


"jtz" <jtz@xxxxxx> wrote in message
news:EC1D21FE-2455-4573-B002-C2D00B484149@xxxxxx
Quote:

> I'm writing code in VBscript for a web project and I find the
> getElementById
> method
> seems doesn't work in VBscipt.the code "set obj=eval('input1')" work,but
> when the code is "set obj=document.getElement ById('input1')",I get
> "nothing"
> by "msgbox typeName(obj)".what is the matter?
> jtz

My System SpecsSystem Spec
Old 11-10-2008   #3 (permalink)
mayayana


 
 

Re: getElemetById doesn't work in VBscipt

Maybe I've missed something, but I've never
understood why that function is necessary.
It works perfeclt well to just use input1 as an
object if there's an element with that ID in
the page.
Quote:

> I'm writing code in VBscript for a web project and I find the
getElementById
Quote:

> method
> seems doesn't work in VBscipt.the code "set obj=eval('input1')" work,but
> when the code is "set obj=document.getElement ById('input1')",I get
"nothing"
Quote:

> by "msgbox typeName(obj)".what is the matter?
> jtz

My System SpecsSystem Spec
Old 11-11-2008   #4 (permalink)
jtz


 
 

Re: getElemetById doesn't work in VBscipt

in fact ,I have a lot of inputs in page ,and I have to iterate these inputs
and get their values.But it is probably that some inputs do not exist,so I
have to use getElemetById mothod to check if the input does exist(using eval
finction will get error),so my actual code is"for i=0 to n set
obj=document.getElemetById("input"&i) if not(obj is nothing )then
........",but everytime obj is returned as nothing,I have no idea what is the
matter and how to solve this problem.
--
jtz


"mayayana" wrote:
Quote:

> Maybe I've missed something, but I've never
> understood why that function is necessary.
> It works perfeclt well to just use input1 as an
> object if there's an element with that ID in
> the page.

My System SpecsSystem Spec
Old 11-11-2008   #5 (permalink)
Tom Lavedas


 
 

Re: getElemetById doesn't work in VBscipt

On Nov 11, 1:27*am, jtz <j...@xxxxxx> wrote:
Quote:

> in fact ,I have a lot of inputs in page ,and I have to iterate these inputs
> and get their values.But it is probably that some inputs do not exist,so I
> have to use getElemetById mothod to check if the input does exist(using eval
> finction will get error),so my actual code is"for i=0 to n * *set
> obj=document.getElemetById("input"&i) * if not(obj is nothing )then
> .......",but everytime obj is *returned as nothing,I have no idea what is the
> matter and how to solve this problem.
> --
> jtz
>
> "mayayana" wrote:
Quote:

> > *Maybe I've missed something, but I've never
> > understood why that function is necessary.
> > It works perfeclt well to just use input1 as an
> > object if there's an element with that ID in
> > the page.
If this IS you 'actual' code ...

for i=0 to n
set obj=document.getElemetById("input"&i)
if not(obj is nothing) then ...
next

Then there is a typo in the function call. You have the function as
getElemetById, when it should be getElemeNtById.

However, since it is fairly obvious that you are NOT using cut-and-
paste as Tim Williams suggested, it's almost impossible to determine
if that's your problem or not.

Tom Lavedas
***********
http://there.is.no.more/tglbatch/
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
speakers randomly wont work sometimes on laptop but external will sometime work Sound & Audio
Calling Excel PMT from VBScipt vs. PowerShell... PowerShell
all cd's don't work, but dvd's still work Vista hardware & devices
HP LaserJet 1010 don't work in Vista since Beta2 - Advanced 1384 Printing Support drivers for XP don't work Vista print fax & scan
Will all the programs that work on xp work on vista? Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46