• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5514
  • Last Modified:

GetElementbyId or tag with VBScript in HTA

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
SupportECI
Asked:
SupportECI
  • 4
  • 3
1 Solution
 
SupportECIAuthor Commented:
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
 
Ashish PatelCommented:
just try this
document.forms[0].findthisuser.value
0
 
Ashish PatelCommented:
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
SupportECIAuthor Commented:
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
 
Ashish PatelCommented:
Glad to know that its working for you now. Though always use
strSearchUser = document.form1.findthisuser.value
0
 
SupportECIAuthor Commented:
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
 
SupportECIAuthor Commented:
Interestingly it doesn't work when I add document in front.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now