Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Subject: Export HTA values to text file

Original Message
Name: keridbey
Date: May 7, 2008 at 06:11:02 Pacific
Subject: Export HTA values to text file
OS: WinXP Pro
CPU/Ram: 1.83 Ghz / 1 Gb
Model/Manufacturer: Dell
Comment:
I'm trying to write a VB script for an HTA to go with a batch file that has already been written. The batch file currently prompts the user for several port numbers on a switch (one at the time). I'd like the HTA to show 26 checkboxes (one for each port), and allow the user to check off whatever they need to, click a "Perform Action" button at the bottom, and the HTA will export the numbers to a text file that the batch file can use (comma delimited would probably be the easiest format). This is probably a simple operation, but I've actually not had much luck finding anything on the web for some reason (maybe I'm looking in the wrong places). Here's what I have so far:

<html>
<head>
<HTA:APPLICATION
APPLICATIONNAME="PortCheckboxes"
SCROLL="no"
SINGLEINSTANCE="yes"
>
</head>

<SCRIPT LANGUAGE="VBScript">
Sub OutputPorts
If Checkbox1.Checked Then
'Here's where the functionality will go.
End If
If Checkbox2.Checked Then
'More functionality, and so on...
End If
End Sub

</SCRIPT>

<body>
<input type="checkbox" name="Checkbox1"> 01
<input type="checkbox" name="Checkbox2"> 02
<input type="checkbox" name="Checkbox3"> 03
<input type="checkbox" name="Checkbox4"> 04
<!--...and so on...-->
<input id=runbutton class="button" type="button" value="Perform Action" name="run_button" onClick="OutputPorts">
</body>

What might be the best way to go about this? Thanks!!


Report Offensive Message For Removal

Response Number 1
Name: Razor2.3
Date: May 7, 2008 at 22:11:35 Pacific
Subject: Export HTA values to text file
Reply: (edit)
Oh, where to begin....

1) In the tags, everything after an equals sign should either be a number or in quotes. It may also be a number in quotes.

2) Input tags should appear only inside of <FORM></FORM> tags

3) Your Script tags should be inside the Head tags.

4) There are easier ways to do go about your task than using Copy/Paste 25 times.

5) You probably couldn't find what you were looking for because your functionality is so ambiguous, and the first step of a programmer or scripter is to remove all ambiguity.

With that out of the way, I rewrote your app. It doesn't look pretty, and it doesn't do what you want. That's partly because of the fore mentioned ambiguity, and partly because I couldn't be bothered to take a whole five minutes on your problem.

<html>
<head>
<HTA:APPLICATION
APPLICATIONNAME="PortCheckboxes"
SCROLL="no" SINGLEINSTANCE="yes">

<script language="VBScript">
Sub BuildPorts
Dim b, f, i
Set f = Document.Forms("ports")

For i = 0 To 25
f.innerHTML = f.innerHTML _
& "<input type=""checkbox"" name=""chkBx"">" & (i + 1) & "<br>"
Next

Set b = Document.createElement("input")
With b
.type = "button"
.value = "Preform Action"
.id = "runbutton"
.name = "runButton"
.attachEvent "onclick", GetRef("OutputPorts")
End With
f.AppendChild b
End Sub

Sub OutputPorts
Dim c, sLine
For Each c In Document.GetElementsByName("chkBx")
sLine = sLine & CStr(Int(c.checked) And 1) & ","
c.checked = False
Next
With CreateObject("Scripting.FileSystemObject")
With .CreateTextFile("a.hta.txt")
.WriteLine Left(sLine, Len(sLine) - 1)
.Close
End With
End With
End Sub
</script>
</head>
<body onload="BuildPorts">
<form id="ports">
</form>
</body>
</html>



Report Offensive Follow Up For Removal

Response Number 2
Name: keridbey
Date: May 9, 2008 at 06:12:50 Pacific
Subject: Export HTA values to text file
Reply: (edit)
Sorry, I've not had a lot of time studying VBS or HTML yet; I've got ideas for solutions, but not a lot of design experience yet; most of what I've learned has just been from picking apart scripts written by others. I will continue to work on this script.

Report Offensive Follow Up For Removal



Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Export HTA values to text file

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software



Version Tracker Pro
Keep your software current and secure, effortlessly

Click Here for a Free Scan

Driver Agent
Automatically find the latest drivers for your computer.
Click Here for a Free Scan



The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC