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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to call a vbscript with arguments from html?

Status
Not open for further replies.

Niavlys

IS-IT--Management
Jun 3, 2002
197
CA
Hi, I need to call a vbscript from a HTML form and pass variables to it with a submit button.

Is it possible? Help me please
 
onSubmit="function_name(parameter to send)"

example

onSubmit="validate(frm.txt.value)"

then recieve the paremeter like
<script>
function validate(varTXT)
varTXT now olds the value of the text field txt A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
I have a similar problem with my script. As a standalone script (fidm.vbs) it runs just fine and it uploads the file correctly. But when I embedd the script into an HTML page it doesn't work for me. I've pasted part of the code in this message. The message boxes are showing me the correct data but when it goes to ftp it bombs out...no errors just doesn't do it. The window pops up then closes so I don't know what it is telling me on the ftp part. Any help would be greatly appreciated. Thanks,Rich

<body>
<SCRIPT LANGUAGE=&quot;VBScript&quot;>

Sub runFIDM_onClick()
On Error Resume Next

Dim wsh
Dim tsScript
Dim fs
Dim strRemoteSite
Dim strUsrN
Dim strPssW
Dim objFolder
Dim FolderPath
Dim objFolder_Contain
Dim foundFile
Dim strFilename
Dim cdDrive
Dim intWindowStyle
Dim strFtpScriptFileName

Const TemporaryFolder = 2
Const WshHide = 0
Const WshNormalFocus = 1
Const WshMinimizedFocus = 2
Const WshMaximizedNoFocus = 3
Const WshNormalNoFocus = 4
Const WshMinimizedNoFocus = 6

'*******************************************************************************
'Retreiving values from form(id=frmGetInfo)

strUsrN = frmGetInfo.txtName.value
strPssW = frmGetInfo.txtPass.value
cdDrive = frmGetInfo.cdDrive.value
'*******************************************************************************

Set wsh = CreateObject(&quot;Wscript.Shell&quot;)
Set fs = CreateObject(&quot;Scripting.FileSystemObject&quot;)

strFtpScriptFileName = fs.BuildPath(fs.GetSpecialFolder(TemporaryFolder), fs.GetBaseName(Wscript.ScriptFullName) & &quot;.script&quot;)

strRemoteSite = &quot;myServer&quot;
intWindowStyle = WshMaximizedNoFocus

FolderPath = cdDrive
Set objFolder = fs.GetFolder(FolderPath)
Set objFolder_Contain = objFolder.Files

For Each foundFile In objFolder_Contain
strFilename = cdDrive & &quot;\&quot; & foundFile.name


'********************************************************************************
'Checking data with MsgBox
MsgBox &quot;File from cd rom: &quot; & strFilename

MsgBox &quot;From Form: &quot; & strUsrN & &quot;\&quot; & strPssW & &quot;\&quot; & cdDrive
'********************************************************************************

Set tsScript = fs.CreateTextFile(strFtpScriptFileName, True)
tsScript.WriteLine &quot;open &quot; & strRemoteSite
tsScript.WriteLine strUsrN
tsScript.WriteLine strPssW
tsScript.WriteLine &quot;hash&quot;

tsScript.WriteLine &quot;ascii&quot;
tsScript.WriteLine &quot;put &quot; & strFilename & &quot; test1&quot;

tsScript.WriteLine &quot;bye&quot;
tsScript.Close
Set tsScript = Nothing

If fs.FileExists(fs.GetSpecialFolder(1) & &quot;\ftp.exe&quot;) Then
wsh.Run fs.GetSpecialFolder(1) & &quot;\ftp.exe -s:&quot;&quot;&quot; & strFtpScriptFileName & &quot;&quot;&quot;&quot;, intWindowStyle, True
Else
wsh.Run fs.GetSpecialFolder(0) & &quot;\ftp.exe -s:&quot;&quot;&quot; & strFtpScriptFileName & &quot;&quot;&quot;&quot;, intWindowStyle, True
End If

fs.DeleteFile strFtpScriptFileName
fs.DeleteFile strFiles, True

MsgBox &quot;Upload Completed!&quot;

Set fs = Nothing

Next
End Sub
</script>

<FORM id=&quot;frmGetInfo&quot;>
<p align=&quot;center&quot;><b><font face=&quot;Tahoma&quot; size=&quot;6&quot; color=&quot;#000080&quot;><var><em><span style=&quot;letter-spacing: 3&quot;><u>Financial
Institution Data Match (FIDM)</u></span></em></var></font></b></p>
<p align=&quot;center&quot;><font color=&quot;#FF0000&quot;><i>File Extract for the Texas Child
Support Enforcement Program</i></font></p>
<hr color=&quot;#000080&quot;>
<p align=&quot;left&quot;><font color=&quot;#FF0000&quot;><i>Enter Username/Password that you use
for Silverlake access.</i></font></p>
<p align=&quot;left&quot;>Username:<input id=&quot;txtName&quot; type=&quot;text&quot; size=&quot;20&quot;></p>
<p align=&quot;left&quot;>Password:<input id=&quot;txtPass&quot; type=&quot;password&quot; size=&quot;20&quot;></p>
<p align=&quot;left&quot;>CDRom Drive Letter<input id=&quot;cdDrive&quot; type=&quot;text&quot; size=&quot;2&quot;></p>
<p align=&quot;left&quot;><input id=&quot;runFIDM&quot; type=&quot;button&quot; value=&quot;Submit&quot;>  
         <input type=&quot;button&quot; value=&quot;Continue&quot; name=&quot;B1&quot;></p>
<hr color=&quot;#000080&quot;>
<p align=&quot;left&quot;>Once completed you must do the following steps before selecting
continue.</p>
</form>
</body>

</html>
 
the only thing you are doing wrong here is putting the function in the body tag. take it out and put it in the head section and there is a ; not needed in there on line 75.
this is a revised example working
<html>
<head>
<SCRIPT LANGUAGE=&quot;VBScript&quot;>

Sub runFIDM_onClick()
On Error Resume Next

Dim wsh
Dim tsScript
Dim fs
Dim strRemoteSite
Dim strUsrN
Dim strPssW
Dim objFolder
Dim FolderPath
Dim objFolder_Contain
Dim foundFile
Dim strFilename
Dim cdDrive
Dim intWindowStyle
Dim strFtpScriptFileName

Const TemporaryFolder = 2
Const WshHide = 0
Const WshNormalFocus = 1
Const WshMinimizedFocus = 2
Const WshMaximizedNoFocus = 3
Const WshNormalNoFocus = 4
Const WshMinimizedNoFocus = 6

'*******************************************************************************
'Retreiving values from form(id=frmGetInfo)

strUsrN = frmGetInfo.txtName.value
strPssW = frmGetInfo.txtPass.value
cdDrive = frmGetInfo.cdDrive.value
'*******************************************************************************

Set wsh = CreateObject(&quot;Wscript.Shell&quot;)
Set fs = CreateObject(&quot;Scripting.FileSystemObject&quot;)

strFtpScriptFileName = fs.BuildPath(fs.GetSpecialFolder(TemporaryFolder), fs.GetBaseName(Wscript.ScriptFullName) & &quot;.script&quot;)

strRemoteSite = &quot;myServer&quot;
intWindowStyle = WshMaximizedNoFocus

FolderPath = cdDrive
Set objFolder = fs.GetFolder(FolderPath)
Set objFolder_Contain = objFolder.Files

For Each foundFile In objFolder_Contain
strFilename = cdDrive & &quot;\&quot; & foundFile.name


'********************************************************************************
'Checking data with MsgBox
MsgBox &quot;File from cd rom: &quot; & strFilename

MsgBox &quot;From Form: &quot; & strUsrN & &quot;\&quot; & strPssW & &quot;\&quot; & cdDrive
'********************************************************************************

Set tsScript = fs.CreateTextFile(strFtpScriptFileName, True)
tsScript.WriteLine &quot;open &quot; & strRemoteSite
tsScript.WriteLine strUsrN
tsScript.WriteLine strPssW
tsScript.WriteLine &quot;hash&quot;

tsScript.WriteLine &quot;ascii&quot;
tsScript.WriteLine &quot;put &quot; & strFilename & &quot; test1&quot;

tsScript.WriteLine &quot;bye&quot;
tsScript.Close
Set tsScript = Nothing

If fs.FileExists(fs.GetSpecialFolder(1) & &quot;\ftp.exe&quot;) Then
wsh.Run fs.GetSpecialFolder(1) & &quot;\ftp.exe -s:&quot;&quot;&quot; & strFtpScriptFileName & &quot;&quot;&quot;&quot;, intWindowStyle, True
Else
wsh.Run fs.GetSpecialFolder(0) & &quot;\ftp.exe -s:&quot;&quot;&quot; & strFtpScriptFileName & &quot;&quot;&quot;&quot;, intWindowStyle, True
End If

fs.DeleteFile strFtpScriptFileName
fs.DeleteFile strFiles, True

MsgBox &quot;Upload Completed!&quot;

Set fs = Nothing

Next
End Sub
</script>

</head>
<body>
<FORM id=&quot;frmGetInfo&quot;>
<p align=&quot;center&quot;><b><font face=&quot;Tahoma&quot; size=&quot;6&quot; color=&quot;#000080&quot;><var><em><span style=&quot;letter-spacing: 3&quot;><u>Financial
Institution Data Match (FIDM)</u></span></em></var></font></b></p>
<p align=&quot;center&quot;><font color=&quot;#FF0000&quot;><i>File Extract for the Texas Child
Support Enforcement Program</i></font></p>
<hr color=&quot;#000080&quot;>
<p align=&quot;left&quot;><font color=&quot;#FF0000&quot;><i>Enter Username/Password that you use
for Silverlake access.</i></font></p>
<p align=&quot;left&quot;>Username:<input id=&quot;txtName&quot; type=&quot;text&quot; size=&quot;20&quot;></p>
<p align=&quot;left&quot;>Password:<input id=&quot;txtPass&quot; type=&quot;password&quot; size=&quot;20&quot;></p>
<p align=&quot;left&quot;>CDRom Drive Letter<input id=&quot;cdDrive&quot; type=&quot;text&quot; size=&quot;2&quot;></p>
<p align=&quot;left&quot;><input id=&quot;runFIDM&quot; type=&quot;button&quot; value=&quot;Submit&quot;>
<input type=&quot;button&quot; value=&quot;Continue&quot; name=&quot;B1&quot;></p>
<hr color=&quot;#000080&quot;>
<p align=&quot;left&quot;>Once completed you must do the following steps before selecting
continue.</p>
</form>
</body>

</html> A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top