How do you set a textbox value from a embeded VbScript?

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

Indy
Ebase User
Posts: 11
Joined: Thu Sep 13, 2007 8:20 am
Location: North Herts District Council

How do you set a textbox value from a embeded VbScript?

#1

Postby Indy » Wed Nov 05, 2008 12:12 pm

Hi,

I'm using the following code to get user details by querying Windows.

Code: Select all

<HEAD> <TITLE>VBScript ->Getting UserName</TITLE>
<SCRIPT LANGUAGE="VBScript">
Dim objNet
On Error Resume Next 
Set objNet = CreateObject&#40;"WScript.NetWork"&#41;

Dim strInfo
strInfo = "User Name is " & objNet.UserName & vbCRLF & _
"Computer Name is " & objNet.ComputerName & vbCRLF & _
"Domain Name is " & objNet.UserDomain
Set oUser = GetObject&#40;"WinNT&#58;//" & objNet.UserDomain & "/" & objNet.UserName & ",user"&#41;
strInfo = strInfo & vbCRLF & "Fullname " & oUser.FullName
msgbox strInfo

set oUser = Nothing
Set objNet = Nothing 'Destroy the Object
</SCRIPT>
</HEAD>
</HTML>
My question is how can I set the output into a text box on the eform?
0 x
Indy

User avatar
Joost
Ebase User
Posts: 49
Joined: Fri Sep 14, 2007 6:14 pm
Location: The Netherlands

Re: How do you set a textbox value from a embeded VbScript?

#2

Postby Joost » Thu Nov 06, 2008 10:33 am

Indy wrote:My question is how can I set the output into a text box on the eform?
The following code would set a Ebase uservar formfield.

Code: Select all

call setFieldValueExternal&#40;"$USERVAR1",strInfo&#41;
Should be likewise for any other formfield.
0 x

Indy
Ebase User
Posts: 11
Joined: Thu Sep 13, 2007 8:20 am
Location: North Herts District Council

#3

Postby Indy » Thu Nov 06, 2008 5:01 pm

Hi Joost,

Is that code for version 3.4? I don't see it in the list of in built functions.
0 x
Indy

AJDulk
Ebase User
Posts: 94
Joined: Fri Sep 14, 2007 12:18 pm
Location: The Netherlands
Contact:

How do you set a textbox value from a embeded VbScript?

#4

Postby AJDulk » Fri Nov 07, 2008 8:13 am

Indy,

See the following link for documentation:
Interacting with the Ebase Form from a Panel

Regards,
Antony
0 x

Indy
Ebase User
Posts: 11
Joined: Thu Sep 13, 2007 8:20 am
Location: North Herts District Council

#5

Postby Indy » Tue Nov 11, 2008 3:17 pm

Hi AJDulk,

I'm having some trouble getting the syntax right. If I insert the setFieldValueExternal("$USERVAR1", strInfo) line within the Java Script portion the code doesn't execute. What am I doing wrong?

Code: Select all

<!-- The Name of this File = test2.html --><HTML>
<HEAD> <TITLE>VBScript ->Getting UserName</TITLE>
<SCRIPT LANGUAGE="VBScript">
Dim objNet
On Error Resume Next 'If fail to create object then display error
' &#40;press no message&#41;
Set objNet = CreateObject&#40;"WScript.NetWork"&#41;
If Err.Number <> 0 Then 'If err
MsgBox "Do not press ""No"" If your browser warns you."
Document.Location = "test2.html" 'Display document by placing name again
End if

Dim strInfo
strInfo = "User Name is " & objNet.UserName & vbCRLF & _
"Computer Name is " & objNet.ComputerName & vbCRLF & _
"Domain Name is " & objNet.UserDomain 

setFieldValueExternal&#40;"$USERVAR1", strInfo&#41;
msgbox strInfo

Set objNet = Nothing 'Destroy the Object
</SCRIPT>
</HEAD>
</HTML>
If I remove the line the msgbox appears with the info.
0 x
Indy

User avatar
Joost
Ebase User
Posts: 49
Joined: Fri Sep 14, 2007 6:14 pm
Location: The Netherlands

#6

Postby Joost » Wed Nov 12, 2008 7:14 am

Indy wrote:What am I doing wrong?[...]If I remove the line the msgbox appears with the info.
You want to call (a JavaScript) function from VBScript as if it were a subroutine. Add "call" in front of the javascript function. It may work just omitting the parentheses, but I like to reference a function with them so I use the vbscript call statement.
0 x

Indy
Ebase User
Posts: 11
Joined: Thu Sep 13, 2007 8:20 am
Location: North Herts District Council

#7

Postby Indy » Fri Nov 14, 2008 10:57 am

Hi Joost..

Thanks for the pointers. I got it finally working and it works very well. I now have an eform which captures Fullname, Username, Email, Computer ID and Domain.

Thanks
0 x
Indy


Who is online

Users browsing this forum: No registered users and 115 guests