Solved

GetElementbyId or tag with VBScript in HTA

Posted on 2007-11-20
7
5,146 Views
Last Modified: 2013-11-19
I am trying to write my first hta to allow users access to ADUC.  Right now I am having trouble getting the value of a text box that will be used to search for users.  I have tried all of the following with no success:

document.formname.id.value
document.formname.id.innertext
formname.id.value
set theform = formname |||| theform.id.value

and a dozen other variations of the above and nothing has worked.

I guess this works pretty easy with javascript, but I don't know how to do the AD stuff in javascript.

And what happened to the VBScript zone??? or did I just miss it?
<script language="vbscript">  

strSearchUser = document.getElementsByName.item.findthisuser.value

msgbox (strSearchUser)

</script>
 

<form id=form1>

Type User's First Name Below:<br>

<input type=text name=findthisuser value="mark"><br>

<input type="button" onclick="findusers()" value="Find Users!"><br>

Now Select the User:

<select id="userSelect">

</select>

<br /><br />
 

</form>

Open in new window

0
Comment
Question by:SupportECI
  • 4
  • 3
7 Comments
 
LVL 1

Author Comment

by:SupportECI
Comment Utility
Just noticed the code I pasted shows that there is no id set on the textbox, that was just temporary as I was trying to get it by name.  I had the id set at "findthisuser" as well.

Also I realize this might be easier in javascript, but that is an issue as I do not know how to then get the text into my existing vbscript to get the users.  So if you know how to do that, I guess that would work (although keeping it in one language seems much easier).

thanks all!
0
 
LVL 23

Expert Comment

by:Ashish Patel
Comment Utility
just try this
document.forms[0].findthisuser.value
0
 
LVL 23

Accepted Solution

by:
Ashish Patel earned 500 total points
Comment Utility
Okay here you go. script tag should be below as it fires before the object is loaded.
 

<form id=form1>

Type User's First Name Below:<br>

<input type=text name=findthisuser value="mark"><br>

<input type="button" onclick="findusers()" value="Find Users!"><br>

Now Select the User:

<select id="userSelect">

</select>

<br /><br />
 

</form>

<script language="vbscript">  

strSearchUser = document.form1.findthisuser.value

msgbox (strSearchUser)

</script>

Open in new window

0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 1

Author Comment

by:SupportECI
Comment Utility
Thanks asvforce,

I have the script called by a button to a sub routine, but your "out of order" comment got me to looking at my code and I had some of the html tags out of place  (that's what you get when you cut and paste code).  So once I fixed the head and body tags this line worked perfectly to get the value:

  strSearchUser = form1.findthisuser.value

Thanks again!
0
 
LVL 23

Expert Comment

by:Ashish Patel
Comment Utility
Glad to know that its working for you now. Though always use
strSearchUser = document.form1.findthisuser.value
0
 
LVL 1

Author Closing Comment

by:SupportECI
Comment Utility
gave an A since I didn't post full code and he pointed me in the right direction to fix the code that wasn't posted.
0
 
LVL 1

Author Comment

by:SupportECI
Comment Utility
Interestingly it doesn't work when I add document in front.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logiā€¦
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

744 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

17 Experts available now in Live!

Get 1:1 Help Now