Solved

GetElementbyId or tag with VBScript in HTA

Posted on 2007-11-20
7
5,309 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 1

Author Comment

by:SupportECI
ID: 20320349
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
ID: 20320454
just try this
document.forms[0].findthisuser.value
0
 
LVL 23

Accepted Solution

by:
Ashish Patel earned 500 total points
ID: 20320491
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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 1

Author Comment

by:SupportECI
ID: 20321145
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
ID: 20321184
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
ID: 31410134
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
ID: 20321474
Interestingly it doesn't work when I add document in front.
0

Featured Post

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

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.
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

707 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