Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display VBscript function as a field

Status
Not open for further replies.

lmayer3

Programmer
Jan 20, 2005
6
0
0
US
Good morning,

I have a VBScript function:

<script language="VBScript" type="text/vbscript">
Function Main()
set wshshell = createobject("wscript.shell")
struser = wshShell.ExpandEnvironmentStrings("%USERNAME%")
strdomain = wshShell.ExpandEnvironmentStrings("%USERDOMAIN%")
msgbox struser & strdomain
End Function
</script>

That works great as a Active X script but I want this to display as a value in a text field and I can't find how o do that. Can anyone direct me? Thanks

Laura
 
hi,
assign the return value the function

eg
function Main()
...
Main = strUser & " " & strdomain
end function

to bind the value to a textbox in html
<input type="text" name="blah" id="blah" value="=Main()">

I would also suggest for you to change the name of the function to a more descriptive one.




 
Thanks for that. Now I get %USERNAME% in the text field instead of the login name.
 
Hi,
You dont have to use ActiveX objects to get the user and domain names on an ASP page. You can get them directly with
on you asp page..

Dim LoggedOnUser, ServerName

LoggedOnUser = Request.ServerVariables("Log_User")
ServerName = Request.ServerVariables("Server_Name")

in you html tag...

<input type="text" name="txtLoggedOnUser" value="<% =LoggedOnUser %>">

<input type="text" name="txtServerName" value="<% =ServerName%>">



Thanks
Aiyaz

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top