I'm creating an HTA from which to run some external VBS files. I need to pass from the HTA to the VBS files, the data of some forms (Radio Button). What should I add to the HTA file to accomplish it? And in VBS?
This is the code I have created so far:
<head><title>Dashboard_Script</title></head>
<meta http-equiv="x-ua-compatible" content="IE=10">
<Script language="VBScript">Set Wss=CreateObject("WScript.Shell")</script>
<body><table><tr><td align="center">
<br><br> DASHBOARD SCRIPTS<br>
<form name="Form1">
<input type="Button" name="Button1" value="SalesReport ">
<SCRIPT FOR="Button1" EVENT="onClick" LANGUAGE="VBScript">
Wss.Run("C:\SalesReport.vbs")
</SCRIPT>
<table>
<tr>
<p>Please select Month from:</p>
<th><input type="radio" id="age1" name="age1" value="1">
<label for="age1">1</label><br></th>
<th><input type="radio" id="age1" name="age1" value="2">
<label for="age2">2</label><br></th>
.........................................................
.........................................................
</tr>
</table>
</fieldset>
</form>
Don't use a form. That's for passing data to a server. You can get the value of the selected radio button, but since you must iterate through radio buttons to find out which one is selected, you can just use your loop counter as the month index. Also consider using a Select menu or a series of buttons. The code below shows all three methods. In all cases, it passes the month index on the command line to the VBS script. The code below passes a value of 1-12. However, if the receiving script is set up with an array for the months, it may be more convenient to pass a zero based index (i.e. 0-11). It's a small adjustment.
This code can be expanded, of course, for additional parameters, such as a year.
Note that the code is using MsgBox for debugging purposes. Also, avoid using tables. When it comes time to make it pretty, use Divs with classes and CSS for styling.