bsharath
asked on
Computers inward outward.Any software which can do this.Or a script to take the input from a HTA fiule and store on an excel sheet.
Hi,
Computers inward outward.Any software which can do this.Or a script to take the input from a HTA fiule and store on an excel sheet.
We hire computers so is there a way that an Hta file asks for the .Date,Servicetag,configura tion etc and then store the data to an csv or excel file.Or is there a software which can do this.
Regards
Sharath
Computers inward outward.Any software which can do this.Or a script to take the input from a HTA fiule and store on an excel sheet.
We hire computers so is there a way that an Hta file asks for the .Date,Servicetag,configura
Regards
Sharath
Sharath, as an example of inward computers, here's a sample to save information to a CSV file specified by
strCSVPath = strCSVPath & "ComputerHire.csv"
<head>
<title>Computer Hire Form</title>
<HTA:APPLICATION
APPLICATIONNAME="Computer Hire Form"
BORDER="thin"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
</head>
<script language="VBScript">
' Global variable to hold the path to the text files
' they are defined here to be global, but are assigned
' values in the Window_OnLoad procedure
strCSVPath = ""
Sub Window_OnLoad
intWidth = 800
intHeight = 600
Me.ResizeTo intWidth, intHeight
Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
' This line gets the path from the currently running directory of this HTA
strCSVPath = Mid(Replace(Replace(docume nt.URL, "file://", ""), "%20", " "), 1, InStrRev(Replace(Replace(d ocument.UR L, "file://", ""), "%20", " "), "\"))
If Right(strTextLogPath, 1) <> "\" Then strTextLogPath = strTextLogPath & "\"
strCSVPath = strCSVPath & "ComputerHire.csv"
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
If objFSO.FileExists(strCSVPa th) = False Then
Set objCSVFile = objFSO.CreateTextFile(strC SVPath, True)
objCSVFile.Write """Date"",""Service Tag"",""Configuration"""
objCSVFile.Close
Set objCSVFile = Nothing
End If
txt_date.Value = Date
End Sub
Sub Default_Buttons
If Window.Event.KeyCode = 13 Then
btn_submit.Click
End If
End Sub
Sub Submit_Form
If txt_servicetag.Value = "" Then
MsgBox "Please enter a Service Tag."
txt_servicetag.Focus
ElseIf txt_configuration.Value = "" Then
MsgBox "Please enter the configuration."
txt_configuration.Focus
Else
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Const intForAppending = 8
Set objOutputFile = objFSO.OpenTextFile(strCSV Path, intForAppending, False)
objOutputFile.Write VbCrLf & """" & txt_date.Value & """,""" & txt_servicetag.Value & """,""" & txt_configuration.Value & """"
objOutputFile.Close
Set objOutputFile = Nothing
Set objFSO = Nothing
MsgBox "Thank you for submitting your information."
window.Close
End If
End Sub
</script>
<body STYLE="font:14 pt arial; color:white;filter:progid: DXImageTra nsform.Mic rosoft.Gra dient
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Bu ttons'>
<table width='90%' height = '100%' align='center' border='0'>
<tr>
<td align='center'>
<h3>Computer Hire Form</h3><br>
</td>
</tr
<tr>
<td align='center'>
<table>
<tr>
<td>
Date:
</td>
<td>
<input type="text" maxlength="30" size="40" id="txt_date" name="txt_date" readonly>
</td>
</tr>
<tr>
<td>
Service Tag:
</td>
<td>
<input type="text" maxlength="30" size="40" id="txt_servicetag" name="txt_servicetag">
</td>
</tr>
<tr>
<td>
Configuration:
</td>
<td>
<input type="text" maxlength="80" size="100" id="txt_configuration" name="txt_configuration">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align='center'>
<br>Please note that all fields are required.
</td>
</tr>
<tr>
<td align='center'>
<input type="button" value="Submit" name="btn_submit" onClick="vbs:Submit_Form"> <br><br>
</td>
</tr>
</table>
</body>
Regards,
Rob.
strCSVPath = strCSVPath & "ComputerHire.csv"
<head>
<title>Computer Hire Form</title>
<HTA:APPLICATION
APPLICATIONNAME="Computer Hire Form"
BORDER="thin"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
</head>
<script language="VBScript">
' Global variable to hold the path to the text files
' they are defined here to be global, but are assigned
' values in the Window_OnLoad procedure
strCSVPath = ""
Sub Window_OnLoad
intWidth = 800
intHeight = 600
Me.ResizeTo intWidth, intHeight
Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
' This line gets the path from the currently running directory of this HTA
strCSVPath = Mid(Replace(Replace(docume
If Right(strTextLogPath, 1) <> "\" Then strTextLogPath = strTextLogPath & "\"
strCSVPath = strCSVPath & "ComputerHire.csv"
Set objFSO = CreateObject("Scripting.Fi
If objFSO.FileExists(strCSVPa
Set objCSVFile = objFSO.CreateTextFile(strC
objCSVFile.Write """Date"",""Service Tag"",""Configuration"""
objCSVFile.Close
Set objCSVFile = Nothing
End If
txt_date.Value = Date
End Sub
Sub Default_Buttons
If Window.Event.KeyCode = 13 Then
btn_submit.Click
End If
End Sub
Sub Submit_Form
If txt_servicetag.Value = "" Then
MsgBox "Please enter a Service Tag."
txt_servicetag.Focus
ElseIf txt_configuration.Value = "" Then
MsgBox "Please enter the configuration."
txt_configuration.Focus
Else
Set objFSO = CreateObject("Scripting.Fi
Const intForAppending = 8
Set objOutputFile = objFSO.OpenTextFile(strCSV
objOutputFile.Write VbCrLf & """" & txt_date.Value & """,""" & txt_servicetag.Value & """,""" & txt_configuration.Value & """"
objOutputFile.Close
Set objOutputFile = Nothing
Set objFSO = Nothing
MsgBox "Thank you for submitting your information."
window.Close
End If
End Sub
</script>
<body STYLE="font:14 pt arial; color:white;filter:progid:
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Bu
<table width='90%' height = '100%' align='center' border='0'>
<tr>
<td align='center'>
<h3>Computer Hire Form</h3><br>
</td>
</tr
<tr>
<td align='center'>
<table>
<tr>
<td>
Date:
</td>
<td>
<input type="text" maxlength="30" size="40" id="txt_date" name="txt_date" readonly>
</td>
</tr>
<tr>
<td>
Service Tag:
</td>
<td>
<input type="text" maxlength="30" size="40" id="txt_servicetag" name="txt_servicetag">
</td>
</tr>
<tr>
<td>
Configuration:
</td>
<td>
<input type="text" maxlength="80" size="100" id="txt_configuration" name="txt_configuration">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align='center'>
<br>Please note that all fields are required.
</td>
</tr>
<tr>
<td align='center'>
<input type="button" value="Submit" name="btn_submit" onClick="vbs:Submit_Form">
</td>
</tr>
</table>
</body>
Regards,
Rob.
ASKER
Thanks Rob i just mentioned some data but need to add some more...Sorry to not have mentioned this..As i thought that this is not possible... :-)
Shall just explain the requirment in some time...
Shall just explain the requirment in some time...
ASKER
Fields
Dc No
Date
Asset tag
Monitor
CPU
Keyboard
Mouse
Configuration
All the above has to be repeated until we click the exit button.
As many times we getb 30 or 50 systems at one time...
So the changes for the asset tag or keyboard or mouse or monitor will be just last no change
ex:
When first asset no is entered like R00123 the secound one will be R00124
So need the old data to reflect back after the first submit until exit..
Dc No
Date
Asset tag
Monitor
CPU
Keyboard
Mouse
Configuration
All the above has to be repeated until we click the exit button.
As many times we getb 30 or 50 systems at one time...
So the changes for the asset tag or keyboard or mouse or monitor will be just last no change
ex:
When first asset no is entered like R00123 the secound one will be R00124
So need the old data to reflect back after the first submit until exit..
ASKER
Sorry Rob missed out one thing..
Instead of the configuration i need these boxes..
Make Model Processor RAM HDD1 HDD2 Floppy CD
These have just 2 to 5 choices if possible we can hard code them
Instead of the configuration i need these boxes..
Make Model Processor RAM HDD1 HDD2 Floppy CD
These have just 2 to 5 choices if possible we can hard code them
ASKER
Good Afternoon .
The hta should not finish taking inputs until we have finished entering the whole lot.
An exit button clicked only should close the Hta
The hta should not finish taking inputs until we have finished entering the whole lot.
An exit button clicked only should close the Hta
Sharath, try this:
<head>
<title>Computer Hire Form</title>
<HTA:APPLICATION
APPLICATIONNAME="Computer Hire Form"
BORDER="thin"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
</head>
<script language="VBScript">
' HTA_To_Store_Computer_Data .hta
' https://www.experts-exchange.com/questions/23119848/Computers-inward-outward-Any-software-which-can-do-this-Or-a-script-to-take-the-input-from-a-HTA-fiule-and-store-on-an-excel-sheet.html
' Global variable to hold the path to the text files
' they are defined here to be global, but are assigned
' values in the Window_OnLoad procedure
strCSVPath = ""
Sub Window_OnLoad
intWidth = 900
intHeight = 700
Me.ResizeTo intWidth, intHeight
Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
' This line gets the path from the currently running directory of this HTA
strCSVPath = Mid(Replace(Replace(docume nt.URL, "file://", ""), "%20", " "), 1, InStrRev(Replace(Replace(d ocument.UR L, "file://", ""), "%20", " "), "\"))
If Right(strTextLogPath, 1) <> "\" Then strTextLogPath = strTextLogPath & "\"
strCSVPath = strCSVPath & "ComputerHire.csv"
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
If objFSO.FileExists(strCSVPa th) = False Then
Set objCSVFile = objFSO.CreateTextFile(strC SVPath, True)
objCSVFile.Write """DC Number"",""Date"",""Asset Tag"",""Monitor"",""CPU"", ""Keyboard "",""Make" ",""Model" ",""Proces sor"",""RA M""," & _
"""HDD1"",""HDD2"",""Flopp y Drive"",""CD-ROM"""
objCSVFile.Close
Set objCSVFile = Nothing
End If
txt_date.Value = Date
End Sub
Sub Default_Buttons
If Window.Event.KeyCode = 13 Then
btn_submit.Click
End If
End Sub
Sub Populate_Model
'MsgBox sel_make.Value
strHTML = "<select size='1' id='sel_model' name='sel_model'>" & VbCrLf
strHTML = strHTML & "<option selected id='sel_model_select' value='sel_model_select'>S elect Model...</option>" & VbCrLf
If sel_make.value = "sel_make_dell" Then
strHTML = strHTML & "<option value='Optiplex GX520'>Optiplex GX520</option>" & VbCrLf
strHTML = strHTML & "<option value='Optiplex GX620'>Optiplex GX620</option>" & VbCrLf
ElseIf sel_make.value = "sel_make_hp" Then
strHTML = strHTML & "<option value='HP Compaq DC5750'>HP Compaq DC5750</option>" & VbCrLf
strHTML = strHTML & "<option value='HP Compaq DC7800'>HP Compaq DC7800</option>" & VbCrLf
End If
strHTML = strHTML & "</select>"
span_sel_model.InnerHTML = strHTML
End Sub
Sub Submit_Form
If txt_dcnumber.Value = "" Then
MsgBox "Please enter a DC Number."
txt_dcnumber.Focus
ElseIf txt_assettag.Value = "" Then
MsgBox "Please enter an Asset Tag."
txt_assettag.Focus
ElseIf txt_monitor.Value = "" Then
MsgBox "Please enter a Monitor."
txt_monitor.Focus
ElseIf txt_cpu.Value = "" Then
MsgBox "Please enter a CPU."
txt_cpu.Focus
ElseIf txt_keyboard.Value = "" Then
MsgBox "Please enter a keyboard."
txt_keyboard.Focus
ElseIf sel_make.Value = "sel_make_select" Then
MsgBox "Please select a Make."
sel_make.Focus
ElseIf sel_model.Value = "sel_model_select" Then
MsgBox "Please select a Model."
sel_model.Focus
ElseIf sel_processor.Value = "sel_processor_select" Then
MsgBox "Please select a Processor."
sel_processor.Focus
ElseIf sel_ram.Value = "sel_ram_select" Then
MsgBox "Please select RAM."
sel_ram.Focus
ElseIf sel_hdd1.Value = "sel_hdd1_select" Then
MsgBox "Please select a HDD1."
sel_hdd1.Focus
ElseIf sel_hdd2.Value = "sel_hdd2_select" Then
MsgBox "Please select a HDD2."
sel_hdd2.Focus
ElseIf sel_floppy.Value = "sel_floppy_select" Then
MsgBox "Please select a Floppy Drive."
sel_floppy.Focus
ElseIf sel_cdrom.Value = "sel_cdrom_select" Then
MsgBox "Please select a CD-ROM Drive."
sel_cdrom.Focus
Else
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Const intForAppending = 8
Set objOutputFile = objFSO.OpenTextFile(strCSV Path, intForAppending, False)
objOutputFile.Write VbCrLf & """" & txt_dcnumber.Value & """,""" & txt_date.Value & """,""" & txt_assettag.Value & """," & _
"""" & txt_monitor.Value & """,""" & txt_cpu.Value & """,""" & txt_keyboard.Value & """,""" & sel_make.Value & """," & _
"""" & sel_model.Value & """,""" & sel_processor.Value & """,""" & sel_ram.Value & """,""" & sel_hdd1.Value & """," & _
"""" & sel_hdd2.Value & """,""" & sel_floppy.Value & """,""" & sel_cdrom.Value & """"
objOutputFile.Close
Set objOutputFile = Nothing
Set objFSO = Nothing
MsgBox "Data stored in " & strCSVPath
'==== Clear fields ====
txt_dcnumber.Value = ""
txt_assettag.Value = ""
txt_monitor.Value = ""
txt_cpu.Value = ""
txt_keyboard.Value = ""
sel_make.Value = "sel_make_select"
sel_model.Value = "sel_model_select"
sel_processor.Value = "sel_processor_select"
sel_ram.Value = "sel_ram_select"
sel_hdd1.Value = "sel_hdd1_select"
sel_hdd2.Value = "sel_hdd2_select"
sel_floppy.Value = "sel_floppy_select"
sel_cdrom.Value = "sel_cdrom_select"
'window.Close
End If
End Sub
</script>
<body STYLE="font:14 pt arial; color:white;filter:progid: DXImageTra nsform.Mic rosoft.Gra dient
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Bu ttons'>
<table width='90%' height = '100%' align='center' border='0'>
<tr>
<td align='center'>
<h3>Computer Hire Form</h3><br>
</td>
</tr
<tr>
<td align='center'>
<table border="0">
<tr>
<td>
DC Number:
</td>
<td colspan="2">
<input type="text" maxlength="30" size="40" id="txt_dcnumber" name="txt_dcnumber">
</td>
</tr>
<tr>
<td>
Date:
</td>
<td colspan="2">
<input type="text" maxlength="30" size="40" id="txt_date" name="txt_date" readonly>
</td>
</tr>
<tr>
<td>
Asset Tag:
</td>
<td colspan="2">
<input type="text" maxlength="30" size="40" id="txt_assettag" name="txt_assettag">
</td>
</tr>
<tr>
<td>
Monitor:
</td>
<td colspan="2">
<input type="text" maxlength="80" size="100" id="txt_monitor" name="txt_monitor">
</td>
</tr>
<tr>
<td>
CPU:
</td>
<td colspan="2">
<input type="text" maxlength="80" size="100" id="txt_cpu" name="txt_cpu">
</td>
</tr>
<tr>
<td>
Keyboard:
</td>
<td colspan="2">
<input type="text" maxlength="80" size="100" id="txt_keyboard" name="txt_keyboard">
</td>
</tr>
<tr>
<td>
<br><br>Configuration:
</td>
</tr>
<tr>
<td>
Make:   
</td>
<td>
<select size="1" id="sel_make" name="sel_make" onchange="vbs:Populate_Mod el">
<option selected id="sel_make_select" value="sel_make_select">Se lect Make...</option>
<option id="sel_make_dell" value="sel_make_dell">Dell </option>
<option id="sel_make_hp" value="sel_make_hp">HP</op tion>
</select>
</td>
</tr>
<tr>
<td>
Model:   
</td>
<td>
<span id="span_sel_model">
<select size="1" id="sel_model" name="sel_model">
<option selected id="sel_model_select" value="sel_model_select">S elect Model...</option>
</select>
</span>
</td>
</tr>
<tr>
<td>
Processor:   
</td>
<td>
<select size="1" id="sel_processor" name="sel_processor">
<option selected id="sel_processor_select" value="sel_processor_selec t">Select Processor...</option>
<option id="sel_processor_2-8Ghz" value="sel_processor_2-8Gh z">2.8 Ghz</option>
<option id="sel_processor_3-2Ghz" value="sel_processor_3-2Gh z">3.2 Ghz</option>
</select>
</td>
</tr>
<tr>
<td>
RAM:   
</td>
<td>
<select size="1" id="sel_ram" name="sel_ram">
<option selected id="sel_ram_select" value="sel_ram_select">Sel ect RAM...</option>
<option id="sel_ram_512Mb" value="sel_ram_512Mb">512M b</option>
<option id="sel_ram_1Gb" value="sel_ram_1Gb">1Gb</o ption>
</select>
</td>
</tr>
<tr>
<td>
HDD1:   
</td>
<td>
<select size="1" id="sel_hdd1" name="sel_hdd1">
<option selected id="sel_hdd1_select" value="sel_hdd1_select">Se lect HDD1...</option>
<option id="sel_hdd1_20Gb" value="sel_hdd1_20Gb">20 Gb</option>
<option id="sel_hdd1_40Gb" value="sel_hdd1_40Gb">40 Gb</option>
</select>
</td>
</tr>
<tr>
<td>
HDD2:   
</td>
<td>
<select size="1" id="sel_hdd2" name="sel_hdd2">
<option selected id="sel_hdd2_select" value="sel_hdd2_select">Se lect HDD2...</option>
<option id="sel_hdd2_none" value="sel_hdd2_none">None </option>
<option id="sel_hdd2_20Gb" value="sel_hdd2_20Gb">20 Gb</option>
<option id="sel_hdd2_40Gb" value="sel_hdd2_40Gb">40 Gb</option>
</select>
</td>
</tr>
<tr>
<td>
Floppy Drive:   
</td>
<td>
<select size="1" id="sel_floppy" name="sel_floppy">
<option selected id="sel_floppy_select" value="sel_floppy_select"> Select Floppy...</option>
<option id="sel_floppy_yes" value="sel_floppy_yes">Yes </option>
<option id="sel_floppy_no" value="sel_floppy_no">No</ option>
</select>
</td>
</tr>
<tr>
<td>
CD-ROM:   
</td>
<td>
<select size="1" id="sel_cdrom" name="sel_cdrom">
<option selected id="sel_cdrom_select" value="sel_cdrom_select">S elect CD-ROM...</option>
<option id="sel_cdrom_none" value="sel_cdrom_none">Non e</option>
<option id="sel_cdrom_52x" value="sel_cdrom_52x">52X CD-ROM</option>
<option id="sel_cdrom_dvd_rom" value="sel_cdrom_dvd_rom"> CD-ROM / DVD-ROM Combo</option>
<option id="sel_cdrom_dvd_dl" value="sel_cdrom_dvd_dl">D ual Layer DVD Burner</option>
</select>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align='center'>
<br>Please note that all fields are required.
</td>
</tr>
<tr>
<td align='center'>
<input type="button" value="Submit" name="btn_submit" onClick="vbs:Submit_Form"> <br><br>
</td>
</tr>
</table>
</body>
Regards,
Rob.
<head>
<title>Computer Hire Form</title>
<HTA:APPLICATION
APPLICATIONNAME="Computer Hire Form"
BORDER="thin"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
</head>
<script language="VBScript">
' HTA_To_Store_Computer_Data
' https://www.experts-exchange.com/questions/23119848/Computers-inward-outward-Any-software-which-can-do-this-Or-a-script-to-take-the-input-from-a-HTA-fiule-and-store-on-an-excel-sheet.html
' Global variable to hold the path to the text files
' they are defined here to be global, but are assigned
' values in the Window_OnLoad procedure
strCSVPath = ""
Sub Window_OnLoad
intWidth = 900
intHeight = 700
Me.ResizeTo intWidth, intHeight
Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
' This line gets the path from the currently running directory of this HTA
strCSVPath = Mid(Replace(Replace(docume
If Right(strTextLogPath, 1) <> "\" Then strTextLogPath = strTextLogPath & "\"
strCSVPath = strCSVPath & "ComputerHire.csv"
Set objFSO = CreateObject("Scripting.Fi
If objFSO.FileExists(strCSVPa
Set objCSVFile = objFSO.CreateTextFile(strC
objCSVFile.Write """DC Number"",""Date"",""Asset Tag"",""Monitor"",""CPU"",
"""HDD1"",""HDD2"",""Flopp
objCSVFile.Close
Set objCSVFile = Nothing
End If
txt_date.Value = Date
End Sub
Sub Default_Buttons
If Window.Event.KeyCode = 13 Then
btn_submit.Click
End If
End Sub
Sub Populate_Model
'MsgBox sel_make.Value
strHTML = "<select size='1' id='sel_model' name='sel_model'>" & VbCrLf
strHTML = strHTML & "<option selected id='sel_model_select' value='sel_model_select'>S
If sel_make.value = "sel_make_dell" Then
strHTML = strHTML & "<option value='Optiplex GX520'>Optiplex GX520</option>" & VbCrLf
strHTML = strHTML & "<option value='Optiplex GX620'>Optiplex GX620</option>" & VbCrLf
ElseIf sel_make.value = "sel_make_hp" Then
strHTML = strHTML & "<option value='HP Compaq DC5750'>HP Compaq DC5750</option>" & VbCrLf
strHTML = strHTML & "<option value='HP Compaq DC7800'>HP Compaq DC7800</option>" & VbCrLf
End If
strHTML = strHTML & "</select>"
span_sel_model.InnerHTML = strHTML
End Sub
Sub Submit_Form
If txt_dcnumber.Value = "" Then
MsgBox "Please enter a DC Number."
txt_dcnumber.Focus
ElseIf txt_assettag.Value = "" Then
MsgBox "Please enter an Asset Tag."
txt_assettag.Focus
ElseIf txt_monitor.Value = "" Then
MsgBox "Please enter a Monitor."
txt_monitor.Focus
ElseIf txt_cpu.Value = "" Then
MsgBox "Please enter a CPU."
txt_cpu.Focus
ElseIf txt_keyboard.Value = "" Then
MsgBox "Please enter a keyboard."
txt_keyboard.Focus
ElseIf sel_make.Value = "sel_make_select" Then
MsgBox "Please select a Make."
sel_make.Focus
ElseIf sel_model.Value = "sel_model_select" Then
MsgBox "Please select a Model."
sel_model.Focus
ElseIf sel_processor.Value = "sel_processor_select" Then
MsgBox "Please select a Processor."
sel_processor.Focus
ElseIf sel_ram.Value = "sel_ram_select" Then
MsgBox "Please select RAM."
sel_ram.Focus
ElseIf sel_hdd1.Value = "sel_hdd1_select" Then
MsgBox "Please select a HDD1."
sel_hdd1.Focus
ElseIf sel_hdd2.Value = "sel_hdd2_select" Then
MsgBox "Please select a HDD2."
sel_hdd2.Focus
ElseIf sel_floppy.Value = "sel_floppy_select" Then
MsgBox "Please select a Floppy Drive."
sel_floppy.Focus
ElseIf sel_cdrom.Value = "sel_cdrom_select" Then
MsgBox "Please select a CD-ROM Drive."
sel_cdrom.Focus
Else
Set objFSO = CreateObject("Scripting.Fi
Const intForAppending = 8
Set objOutputFile = objFSO.OpenTextFile(strCSV
objOutputFile.Write VbCrLf & """" & txt_dcnumber.Value & """,""" & txt_date.Value & """,""" & txt_assettag.Value & """," & _
"""" & txt_monitor.Value & """,""" & txt_cpu.Value & """,""" & txt_keyboard.Value & """,""" & sel_make.Value & """," & _
"""" & sel_model.Value & """,""" & sel_processor.Value & """,""" & sel_ram.Value & """,""" & sel_hdd1.Value & """," & _
"""" & sel_hdd2.Value & """,""" & sel_floppy.Value & """,""" & sel_cdrom.Value & """"
objOutputFile.Close
Set objOutputFile = Nothing
Set objFSO = Nothing
MsgBox "Data stored in " & strCSVPath
'==== Clear fields ====
txt_dcnumber.Value = ""
txt_assettag.Value = ""
txt_monitor.Value = ""
txt_cpu.Value = ""
txt_keyboard.Value = ""
sel_make.Value = "sel_make_select"
sel_model.Value = "sel_model_select"
sel_processor.Value = "sel_processor_select"
sel_ram.Value = "sel_ram_select"
sel_hdd1.Value = "sel_hdd1_select"
sel_hdd2.Value = "sel_hdd2_select"
sel_floppy.Value = "sel_floppy_select"
sel_cdrom.Value = "sel_cdrom_select"
'window.Close
End If
End Sub
</script>
<body STYLE="font:14 pt arial; color:white;filter:progid:
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Bu
<table width='90%' height = '100%' align='center' border='0'>
<tr>
<td align='center'>
<h3>Computer Hire Form</h3><br>
</td>
</tr
<tr>
<td align='center'>
<table border="0">
<tr>
<td>
DC Number:
</td>
<td colspan="2">
<input type="text" maxlength="30" size="40" id="txt_dcnumber" name="txt_dcnumber">
</td>
</tr>
<tr>
<td>
Date:
</td>
<td colspan="2">
<input type="text" maxlength="30" size="40" id="txt_date" name="txt_date" readonly>
</td>
</tr>
<tr>
<td>
Asset Tag:
</td>
<td colspan="2">
<input type="text" maxlength="30" size="40" id="txt_assettag" name="txt_assettag">
</td>
</tr>
<tr>
<td>
Monitor:
</td>
<td colspan="2">
<input type="text" maxlength="80" size="100" id="txt_monitor" name="txt_monitor">
</td>
</tr>
<tr>
<td>
CPU:
</td>
<td colspan="2">
<input type="text" maxlength="80" size="100" id="txt_cpu" name="txt_cpu">
</td>
</tr>
<tr>
<td>
Keyboard:
</td>
<td colspan="2">
<input type="text" maxlength="80" size="100" id="txt_keyboard" name="txt_keyboard">
</td>
</tr>
<tr>
<td>
<br><br>Configuration:
</td>
</tr>
<tr>
<td>
Make:   
</td>
<td>
<select size="1" id="sel_make" name="sel_make" onchange="vbs:Populate_Mod
<option selected id="sel_make_select" value="sel_make_select">Se
<option id="sel_make_dell" value="sel_make_dell">Dell
<option id="sel_make_hp" value="sel_make_hp">HP</op
</select>
</td>
</tr>
<tr>
<td>
Model:   
</td>
<td>
<span id="span_sel_model">
<select size="1" id="sel_model" name="sel_model">
<option selected id="sel_model_select" value="sel_model_select">S
</select>
</span>
</td>
</tr>
<tr>
<td>
Processor:   
</td>
<td>
<select size="1" id="sel_processor" name="sel_processor">
<option selected id="sel_processor_select" value="sel_processor_selec
<option id="sel_processor_2-8Ghz" value="sel_processor_2-8Gh
<option id="sel_processor_3-2Ghz" value="sel_processor_3-2Gh
</select>
</td>
</tr>
<tr>
<td>
RAM:   
</td>
<td>
<select size="1" id="sel_ram" name="sel_ram">
<option selected id="sel_ram_select" value="sel_ram_select">Sel
<option id="sel_ram_512Mb" value="sel_ram_512Mb">512M
<option id="sel_ram_1Gb" value="sel_ram_1Gb">1Gb</o
</select>
</td>
</tr>
<tr>
<td>
HDD1:   
</td>
<td>
<select size="1" id="sel_hdd1" name="sel_hdd1">
<option selected id="sel_hdd1_select" value="sel_hdd1_select">Se
<option id="sel_hdd1_20Gb" value="sel_hdd1_20Gb">20 Gb</option>
<option id="sel_hdd1_40Gb" value="sel_hdd1_40Gb">40 Gb</option>
</select>
</td>
</tr>
<tr>
<td>
HDD2:   
</td>
<td>
<select size="1" id="sel_hdd2" name="sel_hdd2">
<option selected id="sel_hdd2_select" value="sel_hdd2_select">Se
<option id="sel_hdd2_none" value="sel_hdd2_none">None
<option id="sel_hdd2_20Gb" value="sel_hdd2_20Gb">20 Gb</option>
<option id="sel_hdd2_40Gb" value="sel_hdd2_40Gb">40 Gb</option>
</select>
</td>
</tr>
<tr>
<td>
Floppy Drive:   
</td>
<td>
<select size="1" id="sel_floppy" name="sel_floppy">
<option selected id="sel_floppy_select" value="sel_floppy_select">
<option id="sel_floppy_yes" value="sel_floppy_yes">Yes
<option id="sel_floppy_no" value="sel_floppy_no">No</
</select>
</td>
</tr>
<tr>
<td>
CD-ROM:   
</td>
<td>
<select size="1" id="sel_cdrom" name="sel_cdrom">
<option selected id="sel_cdrom_select" value="sel_cdrom_select">S
<option id="sel_cdrom_none" value="sel_cdrom_none">Non
<option id="sel_cdrom_52x" value="sel_cdrom_52x">52X CD-ROM</option>
<option id="sel_cdrom_dvd_rom" value="sel_cdrom_dvd_rom">
<option id="sel_cdrom_dvd_dl" value="sel_cdrom_dvd_dl">D
</select>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align='center'>
<br>Please note that all fields are required.
</td>
</tr>
<tr>
<td align='center'>
<input type="button" value="Submit" name="btn_submit" onClick="vbs:Submit_Form">
</td>
</tr>
</table>
</body>
Regards,
Rob.
ASKER
Rob Good Afternoon,
I never expected it to come so well..Thanks for this excellent script..
Just a few changes please...
HDD2 Should have a none box
Date should be changeable.Some time after a day we may enter the data.
When servicetag entered if already exists in the csv it has to get the details .When required to edit the same tag for some mistake done.
I never expected it to come so well..Thanks for this excellent script..
Just a few changes please...
HDD2 Should have a none box
Date should be changeable.Some time after a day we may enter the data.
When servicetag entered if already exists in the csv it has to get the details .When required to edit the same tag for some mistake done.
ASKER
Rob one more thing..After the first Dcname is entered can the dcname be availble until the end.As typing the dcname for each would be a difficult job.If required should be able to change as well.
After the first data entered can the Configuration data also be the same.As every bunch of machine would be of the same config.Some time only they change...
After the first data entered can the Configuration data also be the same.As every bunch of machine would be of the same config.Some time only they change...
Sharath, here it is again, this time without clearing any fields, and also incrementing the Asset Tag by one each time it is submitted.
<head>
<title>Computer Hire Form</title>
<HTA:APPLICATION
APPLICATIONNAME="Computer Hire Form"
BORDER="thin"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
</head>
<script language="VBScript">
' HTA_To_Store_Computer_Data .hta
' https://www.experts-exchange.com/questions/23119848/Computers-inward-outward-Any-software-which-can-do-this-Or-a-script-to-take-the-input-from-a-HTA-fiule-and-store-on-an-excel-sheet.html
' Global variable to hold the path to the text files
' they are defined here to be global, but are assigned
' values in the Window_OnLoad procedure
strCSVPath = ""
Sub Window_OnLoad
intWidth = 900
intHeight = 700
Me.ResizeTo intWidth, intHeight
Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
' This line gets the path from the currently running directory of this HTA
strCSVPath = Mid(Replace(Replace(docume nt.URL, "file://", ""), "%20", " "), 1, InStrRev(Replace(Replace(d ocument.UR L, "file://", ""), "%20", " "), "\"))
If Right(strTextLogPath, 1) <> "\" Then strTextLogPath = strTextLogPath & "\"
strCSVPath = strCSVPath & "ComputerHire.csv"
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
If objFSO.FileExists(strCSVPa th) = False Then
Set objCSVFile = objFSO.CreateTextFile(strC SVPath, True)
objCSVFile.Write """DC Number"",""Date"",""Asset Tag"",""Monitor"",""CPU"", ""Keyboard "",""Make" ",""Model" ",""Proces sor"",""RA M""," & _
"""HDD1"",""HDD2"",""Flopp y Drive"",""CD-ROM"""
objCSVFile.Close
Set objCSVFile = Nothing
End If
txt_date.Value = Date
End Sub
Sub Default_Buttons
If Window.Event.KeyCode = 13 Then
btn_submit.Click
End If
End Sub
Sub Populate_Model
'MsgBox sel_make.Value
strHTML = "<select size='1' id='sel_model' name='sel_model'>" & VbCrLf
strHTML = strHTML & "<option selected id='sel_model_select' value='sel_model_select'>S elect Model...</option>" & VbCrLf
If sel_make.value = "sel_make_dell" Then
strHTML = strHTML & "<option value='Optiplex GX520'>Optiplex GX520</option>" & VbCrLf
strHTML = strHTML & "<option value='Optiplex GX620'>Optiplex GX620</option>" & VbCrLf
ElseIf sel_make.value = "sel_make_hp" Then
strHTML = strHTML & "<option value='HP Compaq DC5750'>HP Compaq DC5750</option>" & VbCrLf
strHTML = strHTML & "<option value='HP Compaq DC7800'>HP Compaq DC7800</option>" & VbCrLf
End If
strHTML = strHTML & "</select>"
span_sel_model.InnerHTML = strHTML
End Sub
Sub Submit_Form
If txt_dcnumber.Value = "" Then
MsgBox "Please enter a DC Number."
txt_dcnumber.Focus
ElseIf txt_assettag.Value = "" Then
MsgBox "Please enter an Asset Tag."
txt_assettag.Focus
ElseIf txt_monitor.Value = "" Then
MsgBox "Please enter a Monitor."
txt_monitor.Focus
ElseIf txt_cpu.Value = "" Then
MsgBox "Please enter a CPU."
txt_cpu.Focus
ElseIf txt_keyboard.Value = "" Then
MsgBox "Please enter a keyboard."
txt_keyboard.Focus
ElseIf sel_make.Value = "sel_make_select" Then
MsgBox "Please select a Make."
sel_make.Focus
ElseIf sel_model.Value = "sel_model_select" Then
MsgBox "Please select a Model."
sel_model.Focus
ElseIf sel_processor.Value = "sel_processor_select" Then
MsgBox "Please select a Processor."
sel_processor.Focus
ElseIf sel_ram.Value = "sel_ram_select" Then
MsgBox "Please select RAM."
sel_ram.Focus
ElseIf sel_hdd1.Value = "sel_hdd1_select" Then
MsgBox "Please select a HDD1."
sel_hdd1.Focus
ElseIf sel_hdd2.Value = "sel_hdd2_select" Then
MsgBox "Please select a HDD2."
sel_hdd2.Focus
ElseIf sel_floppy.Value = "sel_floppy_select" Then
MsgBox "Please select a Floppy Drive."
sel_floppy.Focus
ElseIf sel_cdrom.Value = "sel_cdrom_select" Then
MsgBox "Please select a CD-ROM Drive."
sel_cdrom.Focus
Else
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Const intForAppending = 8
Set objOutputFile = objFSO.OpenTextFile(strCSV Path, intForAppending, False)
objOutputFile.Write VbCrLf & """" & txt_dcnumber.Value & """,""" & txt_date.Value & """,""" & txt_assettag.Value & """," & _
"""" & txt_monitor.Value & """,""" & txt_cpu.Value & """,""" & txt_keyboard.Value & """,""" & sel_make.Value & """," & _
"""" & sel_model.Value & """,""" & sel_processor.Value & """,""" & sel_ram.Value & """,""" & sel_hdd1.Value & """," & _
"""" & sel_hdd2.Value & """,""" & sel_floppy.Value & """,""" & sel_cdrom.Value & """"
objOutputFile.Close
Set objOutputFile = Nothing
Set objFSO = Nothing
MsgBox "Data stored in " & strCSVPath
'=== Increment the Asset tag ===
boolInteger = False
intPos = 0
While boolInteger = False
intPos = intPos + 1
strChar = Mid(txt_assettag.Value, intPos, 1)
If IsNumeric(strChar) = True Then boolInteger = True
Wend
intNumberLength = Len(txt_assettag.Value) - intPos - 1
strNumber = Int(Mid(txt_assettag.Value , intPos)) + 1
strNewTag = Left(txt_assettag.Value, intPos - 1) & String(intNumberLength - Len(intNumber) - (intPos - 1), "0") & strNumber
txt_assettag.Value = strNewTag
'==== Clear fields ====
'txt_dcnumber.Value = ""
'txt_monitor.Value = ""
'txt_cpu.Value = ""
'txt_keyboard.Value = ""
'sel_make.Value = "sel_make_select"
'sel_model.Value = "sel_model_select"
'sel_processor.Value = "sel_processor_select"
'sel_ram.Value = "sel_ram_select"
'sel_hdd1.Value = "sel_hdd1_select"
'sel_hdd2.Value = "sel_hdd2_select"
'sel_floppy.Value = "sel_floppy_select"
'sel_cdrom.Value = "sel_cdrom_select"
'window.Close
End If
End Sub
</script>
<body STYLE="font:14 pt arial; color:white;filter:progid: DXImageTra nsform.Mic rosoft.Gra dient
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Bu ttons'>
<table width='90%' height = '100%' align='center' border='0'>
<tr>
<td align='center'>
<h3>Computer Hire Form</h3><br>
</td>
</tr
<tr>
<td align='center'>
<table border="0">
<tr>
<td>
DC Number:
</td>
<td colspan="2">
<input type="text" maxlength="30" size="40" id="txt_dcnumber" name="txt_dcnumber">
</td>
</tr>
<tr>
<td>
Date:
</td>
<td colspan="2">
<input type="text" maxlength="30" size="40" id="txt_date" name="txt_date">
</td>
</tr>
<tr>
<td>
Asset Tag:
</td>
<td colspan="2">
<input type="text" maxlength="30" size="40" id="txt_assettag" name="txt_assettag">
</td>
</tr>
<tr>
<td>
Monitor:
</td>
<td colspan="2">
<input type="text" maxlength="80" size="100" id="txt_monitor" name="txt_monitor">
</td>
</tr>
<tr>
<td>
CPU:
</td>
<td colspan="2">
<input type="text" maxlength="80" size="100" id="txt_cpu" name="txt_cpu">
</td>
</tr>
<tr>
<td>
Keyboard:
</td>
<td colspan="2">
<input type="text" maxlength="80" size="100" id="txt_keyboard" name="txt_keyboard">
</td>
</tr>
<tr>
<td>
<br><br>Configuration:
</td>
</tr>
<tr>
<td>
Make:   
</td>
<td>
<select size="1" id="sel_make" name="sel_make" onchange="vbs:Populate_Mod el">
<option selected id="sel_make_select" value="sel_make_select">Se lect Make...</option>
<option id="sel_make_dell" value="sel_make_dell">Dell </option>
<option id="sel_make_hp" value="sel_make_hp">HP</op tion>
</select>
</td>
</tr>
<tr>
<td>
Model:   
</td>
<td>
<span id="span_sel_model">
<select size="1" id="sel_model" name="sel_model">
<option selected id="sel_model_select" value="sel_model_select">S elect Model...</option>
</select>
</span>
</td>
</tr>
<tr>
<td>
Processor:   
</td>
<td>
<select size="1" id="sel_processor" name="sel_processor">
<option selected id="sel_processor_select" value="sel_processor_selec t">Select Processor...</option>
<option id="sel_processor_2-8Ghz" value="sel_processor_2-8Gh z">2.8 Ghz</option>
<option id="sel_processor_3-2Ghz" value="sel_processor_3-2Gh z">3.2 Ghz</option>
</select>
</td>
</tr>
<tr>
<td>
RAM:   
</td>
<td>
<select size="1" id="sel_ram" name="sel_ram">
<option selected id="sel_ram_select" value="sel_ram_select">Sel ect RAM...</option>
<option id="sel_ram_512Mb" value="sel_ram_512Mb">512M b</option>
<option id="sel_ram_1Gb" value="sel_ram_1Gb">1Gb</o ption>
</select>
</td>
</tr>
<tr>
<td>
HDD1:   
</td>
<td>
<select size="1" id="sel_hdd1" name="sel_hdd1">
<option selected id="sel_hdd1_select" value="sel_hdd1_select">Se lect HDD1...</option>
<option id="sel_hdd1_20Gb" value="sel_hdd1_20Gb">20 Gb</option>
<option id="sel_hdd1_40Gb" value="sel_hdd1_40Gb">40 Gb</option>
</select>
</td>
</tr>
<tr>
<td>
HDD2:   
</td>
<td>
<select size="1" id="sel_hdd2" name="sel_hdd2">
<option selected id="sel_hdd2_select" value="sel_hdd2_select">Se lect HDD2...</option>
<option id="sel_hdd2_none" value="sel_hdd2_none">None </option>
<option id="sel_hdd2_20Gb" value="sel_hdd2_20Gb">20 Gb</option>
<option id="sel_hdd2_40Gb" value="sel_hdd2_40Gb">40 Gb</option>
</select>
</td>
</tr>
<tr>
<td>
Floppy Drive:   
</td>
<td>
<select size="1" id="sel_floppy" name="sel_floppy">
<option selected id="sel_floppy_select" value="sel_floppy_select"> Select Floppy...</option>
<option id="sel_floppy_yes" value="sel_floppy_yes">Yes </option>
<option id="sel_floppy_no" value="sel_floppy_no">No</ option>
</select>
</td>
</tr>
<tr>
<td>
CD-ROM:   
</td>
<td>
<select size="1" id="sel_cdrom" name="sel_cdrom">
<option selected id="sel_cdrom_select" value="sel_cdrom_select">S elect CD-ROM...</option>
<option id="sel_cdrom_none" value="sel_cdrom_none">Non e</option>
<option id="sel_cdrom_52x" value="sel_cdrom_52x">52X CD-ROM</option>
<option id="sel_cdrom_dvd_rom" value="sel_cdrom_dvd_rom"> CD-ROM / DVD-ROM Combo</option>
<option id="sel_cdrom_dvd_dl" value="sel_cdrom_dvd_dl">D ual Layer DVD Burner</option>
</select>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align='center'>
<br>Please note that all fields are required.
</td>
</tr>
<tr>
<td align='center'>
<input type="button" value="Submit" name="btn_submit" onClick="vbs:Submit_Form"> <br><br>
</td>
</tr>
</table>
</body>
Regards,
Rob.
<head>
<title>Computer Hire Form</title>
<HTA:APPLICATION
APPLICATIONNAME="Computer Hire Form"
BORDER="thin"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
</head>
<script language="VBScript">
' HTA_To_Store_Computer_Data
' https://www.experts-exchange.com/questions/23119848/Computers-inward-outward-Any-software-which-can-do-this-Or-a-script-to-take-the-input-from-a-HTA-fiule-and-store-on-an-excel-sheet.html
' Global variable to hold the path to the text files
' they are defined here to be global, but are assigned
' values in the Window_OnLoad procedure
strCSVPath = ""
Sub Window_OnLoad
intWidth = 900
intHeight = 700
Me.ResizeTo intWidth, intHeight
Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
' This line gets the path from the currently running directory of this HTA
strCSVPath = Mid(Replace(Replace(docume
If Right(strTextLogPath, 1) <> "\" Then strTextLogPath = strTextLogPath & "\"
strCSVPath = strCSVPath & "ComputerHire.csv"
Set objFSO = CreateObject("Scripting.Fi
If objFSO.FileExists(strCSVPa
Set objCSVFile = objFSO.CreateTextFile(strC
objCSVFile.Write """DC Number"",""Date"",""Asset Tag"",""Monitor"",""CPU"",
"""HDD1"",""HDD2"",""Flopp
objCSVFile.Close
Set objCSVFile = Nothing
End If
txt_date.Value = Date
End Sub
Sub Default_Buttons
If Window.Event.KeyCode = 13 Then
btn_submit.Click
End If
End Sub
Sub Populate_Model
'MsgBox sel_make.Value
strHTML = "<select size='1' id='sel_model' name='sel_model'>" & VbCrLf
strHTML = strHTML & "<option selected id='sel_model_select' value='sel_model_select'>S
If sel_make.value = "sel_make_dell" Then
strHTML = strHTML & "<option value='Optiplex GX520'>Optiplex GX520</option>" & VbCrLf
strHTML = strHTML & "<option value='Optiplex GX620'>Optiplex GX620</option>" & VbCrLf
ElseIf sel_make.value = "sel_make_hp" Then
strHTML = strHTML & "<option value='HP Compaq DC5750'>HP Compaq DC5750</option>" & VbCrLf
strHTML = strHTML & "<option value='HP Compaq DC7800'>HP Compaq DC7800</option>" & VbCrLf
End If
strHTML = strHTML & "</select>"
span_sel_model.InnerHTML = strHTML
End Sub
Sub Submit_Form
If txt_dcnumber.Value = "" Then
MsgBox "Please enter a DC Number."
txt_dcnumber.Focus
ElseIf txt_assettag.Value = "" Then
MsgBox "Please enter an Asset Tag."
txt_assettag.Focus
ElseIf txt_monitor.Value = "" Then
MsgBox "Please enter a Monitor."
txt_monitor.Focus
ElseIf txt_cpu.Value = "" Then
MsgBox "Please enter a CPU."
txt_cpu.Focus
ElseIf txt_keyboard.Value = "" Then
MsgBox "Please enter a keyboard."
txt_keyboard.Focus
ElseIf sel_make.Value = "sel_make_select" Then
MsgBox "Please select a Make."
sel_make.Focus
ElseIf sel_model.Value = "sel_model_select" Then
MsgBox "Please select a Model."
sel_model.Focus
ElseIf sel_processor.Value = "sel_processor_select" Then
MsgBox "Please select a Processor."
sel_processor.Focus
ElseIf sel_ram.Value = "sel_ram_select" Then
MsgBox "Please select RAM."
sel_ram.Focus
ElseIf sel_hdd1.Value = "sel_hdd1_select" Then
MsgBox "Please select a HDD1."
sel_hdd1.Focus
ElseIf sel_hdd2.Value = "sel_hdd2_select" Then
MsgBox "Please select a HDD2."
sel_hdd2.Focus
ElseIf sel_floppy.Value = "sel_floppy_select" Then
MsgBox "Please select a Floppy Drive."
sel_floppy.Focus
ElseIf sel_cdrom.Value = "sel_cdrom_select" Then
MsgBox "Please select a CD-ROM Drive."
sel_cdrom.Focus
Else
Set objFSO = CreateObject("Scripting.Fi
Const intForAppending = 8
Set objOutputFile = objFSO.OpenTextFile(strCSV
objOutputFile.Write VbCrLf & """" & txt_dcnumber.Value & """,""" & txt_date.Value & """,""" & txt_assettag.Value & """," & _
"""" & txt_monitor.Value & """,""" & txt_cpu.Value & """,""" & txt_keyboard.Value & """,""" & sel_make.Value & """," & _
"""" & sel_model.Value & """,""" & sel_processor.Value & """,""" & sel_ram.Value & """,""" & sel_hdd1.Value & """," & _
"""" & sel_hdd2.Value & """,""" & sel_floppy.Value & """,""" & sel_cdrom.Value & """"
objOutputFile.Close
Set objOutputFile = Nothing
Set objFSO = Nothing
MsgBox "Data stored in " & strCSVPath
'=== Increment the Asset tag ===
boolInteger = False
intPos = 0
While boolInteger = False
intPos = intPos + 1
strChar = Mid(txt_assettag.Value, intPos, 1)
If IsNumeric(strChar) = True Then boolInteger = True
Wend
intNumberLength = Len(txt_assettag.Value) - intPos - 1
strNumber = Int(Mid(txt_assettag.Value
strNewTag = Left(txt_assettag.Value, intPos - 1) & String(intNumberLength - Len(intNumber) - (intPos - 1), "0") & strNumber
txt_assettag.Value = strNewTag
'==== Clear fields ====
'txt_dcnumber.Value = ""
'txt_monitor.Value = ""
'txt_cpu.Value = ""
'txt_keyboard.Value = ""
'sel_make.Value = "sel_make_select"
'sel_model.Value = "sel_model_select"
'sel_processor.Value = "sel_processor_select"
'sel_ram.Value = "sel_ram_select"
'sel_hdd1.Value = "sel_hdd1_select"
'sel_hdd2.Value = "sel_hdd2_select"
'sel_floppy.Value = "sel_floppy_select"
'sel_cdrom.Value = "sel_cdrom_select"
'window.Close
End If
End Sub
</script>
<body STYLE="font:14 pt arial; color:white;filter:progid:
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Bu
<table width='90%' height = '100%' align='center' border='0'>
<tr>
<td align='center'>
<h3>Computer Hire Form</h3><br>
</td>
</tr
<tr>
<td align='center'>
<table border="0">
<tr>
<td>
DC Number:
</td>
<td colspan="2">
<input type="text" maxlength="30" size="40" id="txt_dcnumber" name="txt_dcnumber">
</td>
</tr>
<tr>
<td>
Date:
</td>
<td colspan="2">
<input type="text" maxlength="30" size="40" id="txt_date" name="txt_date">
</td>
</tr>
<tr>
<td>
Asset Tag:
</td>
<td colspan="2">
<input type="text" maxlength="30" size="40" id="txt_assettag" name="txt_assettag">
</td>
</tr>
<tr>
<td>
Monitor:
</td>
<td colspan="2">
<input type="text" maxlength="80" size="100" id="txt_monitor" name="txt_monitor">
</td>
</tr>
<tr>
<td>
CPU:
</td>
<td colspan="2">
<input type="text" maxlength="80" size="100" id="txt_cpu" name="txt_cpu">
</td>
</tr>
<tr>
<td>
Keyboard:
</td>
<td colspan="2">
<input type="text" maxlength="80" size="100" id="txt_keyboard" name="txt_keyboard">
</td>
</tr>
<tr>
<td>
<br><br>Configuration:
</td>
</tr>
<tr>
<td>
Make:   
</td>
<td>
<select size="1" id="sel_make" name="sel_make" onchange="vbs:Populate_Mod
<option selected id="sel_make_select" value="sel_make_select">Se
<option id="sel_make_dell" value="sel_make_dell">Dell
<option id="sel_make_hp" value="sel_make_hp">HP</op
</select>
</td>
</tr>
<tr>
<td>
Model:   
</td>
<td>
<span id="span_sel_model">
<select size="1" id="sel_model" name="sel_model">
<option selected id="sel_model_select" value="sel_model_select">S
</select>
</span>
</td>
</tr>
<tr>
<td>
Processor:   
</td>
<td>
<select size="1" id="sel_processor" name="sel_processor">
<option selected id="sel_processor_select" value="sel_processor_selec
<option id="sel_processor_2-8Ghz" value="sel_processor_2-8Gh
<option id="sel_processor_3-2Ghz" value="sel_processor_3-2Gh
</select>
</td>
</tr>
<tr>
<td>
RAM:   
</td>
<td>
<select size="1" id="sel_ram" name="sel_ram">
<option selected id="sel_ram_select" value="sel_ram_select">Sel
<option id="sel_ram_512Mb" value="sel_ram_512Mb">512M
<option id="sel_ram_1Gb" value="sel_ram_1Gb">1Gb</o
</select>
</td>
</tr>
<tr>
<td>
HDD1:   
</td>
<td>
<select size="1" id="sel_hdd1" name="sel_hdd1">
<option selected id="sel_hdd1_select" value="sel_hdd1_select">Se
<option id="sel_hdd1_20Gb" value="sel_hdd1_20Gb">20 Gb</option>
<option id="sel_hdd1_40Gb" value="sel_hdd1_40Gb">40 Gb</option>
</select>
</td>
</tr>
<tr>
<td>
HDD2:   
</td>
<td>
<select size="1" id="sel_hdd2" name="sel_hdd2">
<option selected id="sel_hdd2_select" value="sel_hdd2_select">Se
<option id="sel_hdd2_none" value="sel_hdd2_none">None
<option id="sel_hdd2_20Gb" value="sel_hdd2_20Gb">20 Gb</option>
<option id="sel_hdd2_40Gb" value="sel_hdd2_40Gb">40 Gb</option>
</select>
</td>
</tr>
<tr>
<td>
Floppy Drive:   
</td>
<td>
<select size="1" id="sel_floppy" name="sel_floppy">
<option selected id="sel_floppy_select" value="sel_floppy_select">
<option id="sel_floppy_yes" value="sel_floppy_yes">Yes
<option id="sel_floppy_no" value="sel_floppy_no">No</
</select>
</td>
</tr>
<tr>
<td>
CD-ROM:   
</td>
<td>
<select size="1" id="sel_cdrom" name="sel_cdrom">
<option selected id="sel_cdrom_select" value="sel_cdrom_select">S
<option id="sel_cdrom_none" value="sel_cdrom_none">Non
<option id="sel_cdrom_52x" value="sel_cdrom_52x">52X CD-ROM</option>
<option id="sel_cdrom_dvd_rom" value="sel_cdrom_dvd_rom">
<option id="sel_cdrom_dvd_dl" value="sel_cdrom_dvd_dl">D
</select>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align='center'>
<br>Please note that all fields are required.
</td>
</tr>
<tr>
<td align='center'>
<input type="button" value="Submit" name="btn_submit" onClick="vbs:Submit_Form">
</td>
</tr>
</table>
</body>
Regards,
Rob.
ASKER
Rob after submitting after a long time i get this...
-------------------------- -
Computer Hire Form
-------------------------- -
Stop running this script?
A script on this page is causing Internet Explorer to run slowly.
If it continues to run, your computer may become
unresponsive.
-------------------------- -
Yes No
-------------------------- -
--------------------------
Computer Hire Form
--------------------------
Stop running this script?
A script on this page is causing Internet Explorer to run slowly.
If it continues to run, your computer may become
unresponsive.
--------------------------
Yes No
--------------------------
There must be a problem with the "next number" logic....replace this:
'=== Increment the Asset tag ===
boolInteger = False
intPos = 0
While boolInteger = False
intPos = intPos + 1
strChar = Mid(txt_assettag.Value, intPos, 1)
If IsNumeric(strChar) = True Then boolInteger = True
Wend
intNumberLength = Len(txt_assettag.Value) - intPos - 1
strNumber = Int(Mid(txt_assettag.Value , intPos)) + 1
strNewTag = Left(txt_assettag.Value, intPos - 1) & String(intNumberLength - Len(intNumber) - (intPos - 1), "0") & strNumber
txt_assettag.Value = strNewTag
'==== Clear fields ====
with this:
'=== Increment the Asset tag ===
boolInteger = False
intPos = 0
While boolInteger = False
intPos = intPos + 1
If intPos > Len(txt_assettag.Value) Then boolInteger = True
strChar = Mid(txt_assettag.Value, intPos, 1)
If IsNumeric(strChar) = True Then boolInteger = True
Wend
If intPos <= Len(txt_assettag.Value) Then
strNumber = Mid(txt_assettag.Value, intPos)
intNumberLength = Len(strNumber)
intNextNumber = Int(strNumber) + 1
MsgBox Left(txt_assettag.Value, intPos - 1) & String(intNumberLength - Len(intNextNumber), "0") & intNextNumber
strNewTag = Left(txt_assettag.Value, intPos - 1) & String(intNumberLength - Len(intNextNumber), "0") & intNextNumber
txt_assettag.Value = strNewTag
Else
txt_assettag.Value = ""
End If
'==== Clear fields ====
Regards,
Rob.
'=== Increment the Asset tag ===
boolInteger = False
intPos = 0
While boolInteger = False
intPos = intPos + 1
strChar = Mid(txt_assettag.Value, intPos, 1)
If IsNumeric(strChar) = True Then boolInteger = True
Wend
intNumberLength = Len(txt_assettag.Value) - intPos - 1
strNumber = Int(Mid(txt_assettag.Value
strNewTag = Left(txt_assettag.Value, intPos - 1) & String(intNumberLength - Len(intNumber) - (intPos - 1), "0") & strNumber
txt_assettag.Value = strNewTag
'==== Clear fields ====
with this:
'=== Increment the Asset tag ===
boolInteger = False
intPos = 0
While boolInteger = False
intPos = intPos + 1
If intPos > Len(txt_assettag.Value) Then boolInteger = True
strChar = Mid(txt_assettag.Value, intPos, 1)
If IsNumeric(strChar) = True Then boolInteger = True
Wend
If intPos <= Len(txt_assettag.Value) Then
strNumber = Mid(txt_assettag.Value, intPos)
intNumberLength = Len(strNumber)
intNextNumber = Int(strNumber) + 1
MsgBox Left(txt_assettag.Value, intPos - 1) & String(intNumberLength - Len(intNextNumber), "0") & intNextNumber
strNewTag = Left(txt_assettag.Value, intPos - 1) & String(intNumberLength - Len(intNextNumber), "0") & intNextNumber
txt_assettag.Value = strNewTag
Else
txt_assettag.Value = ""
End If
'==== Clear fields ====
Regards,
Rob.
ASKER
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot Rob....
ASKER
Rob the report in the csv file in this HTA get results as this...
Make Model Processor RAM HDD1 HDD2 Floppy Drive CD-ROM
sel_make_dell Optiplex GX520 sel_processor_2-8Ghz sel_ram_512Mb sel_hdd1_20Gb sel_hdd2_none sel_floppy_yes sel_cdrom_none
sel_make_dell Optiplex GX520 sel_processor_2-8Ghz sel_ram_512Mb sel_hdd1_20Gb sel_hdd2_none sel_floppy_yes sel_cdrom_none
sel_make_dell Optiplex GX520 sel_processor_2-8Ghz sel_ram_512Mb sel_hdd1_20Gb sel_hdd2_none sel_floppy_yes sel_cdrom_none
sel_make_dell Optiplex GX520 sel_processor_2-8Ghz sel_ram_512Mb sel_hdd1_20Gb sel_hdd2_none sel_floppy_yes sel_cdrom_none
Can we remove "sel_hdd1_" for all the selections....
If i need to add another "Model" or "Make" how do i do?
Make Model Processor RAM HDD1 HDD2 Floppy Drive CD-ROM
sel_make_dell Optiplex GX520 sel_processor_2-8Ghz sel_ram_512Mb sel_hdd1_20Gb sel_hdd2_none sel_floppy_yes sel_cdrom_none
sel_make_dell Optiplex GX520 sel_processor_2-8Ghz sel_ram_512Mb sel_hdd1_20Gb sel_hdd2_none sel_floppy_yes sel_cdrom_none
sel_make_dell Optiplex GX520 sel_processor_2-8Ghz sel_ram_512Mb sel_hdd1_20Gb sel_hdd2_none sel_floppy_yes sel_cdrom_none
sel_make_dell Optiplex GX520 sel_processor_2-8Ghz sel_ram_512Mb sel_hdd1_20Gb sel_hdd2_none sel_floppy_yes sel_cdrom_none
Can we remove "sel_hdd1_" for all the selections....
If i need to add another "Model" or "Make" how do i do?
Oh sorry! I didn't even notice that output! I have changed all of the value="...." bits to represent proper names now.
Also, to another Make, add one to this section:
<select size="1" id="sel_make" name="sel_make" onchange="vbs:Populate_Mod el">
<option selected id="sel_make_select" value="sel_make_select">Se lect Make...</option>
<option id="sel_make_dell" value="Dell">Dell</option>
<option id="sel_make_hp" value="HP">HP</option>
</select>
for example, add:
<option id="sel_make_toshiba" value="Toshiba">Toshiba</o ption>
and then to add models for that make (or add to other makes), add that to here
Sub Populate_Model
'MsgBox sel_make.Value
strHTML = "<select size='1' id='sel_model' name='sel_model'>" & VbCrLf
strHTML = strHTML & "<option selected id='sel_model_select' value='sel_model_select'>S elect Model...</option>" & VbCrLf
If sel_make.value = "Dell" Then
strHTML = strHTML & "<option value='Optiplex GX520'>Optiplex GX520</option>" & VbCrLf
strHTML = strHTML & "<option value='Optiplex GX620'>Optiplex GX620</option>" & VbCrLf
ElseIf sel_make.value = "HP" Then
strHTML = strHTML & "<option value='HP Compaq DC5750'>HP Compaq DC5750</option>" & VbCrLf
strHTML = strHTML & "<option value='HP Compaq DC7800'>HP Compaq DC7800</option>" & VbCrLf
End If
strHTML = strHTML & "</select>"
span_sel_model.InnerHTML = strHTML
End Sub
for example, add another make and models:
ElseIf sel_make.value = "Toshiba" Then
strHTML = strHTML & "<option value='Toshiba Satellite Pro 6100'>Toshiba Satellite Pro 6100</option>" & VbCrLf
strHTML = strHTML & "<option value='Toshiba Satellite Pro P200'>Toshiba Satellite Pro P200</option>" & VbCrLf
That should do it.
<head>
<title>Computer Hire Form</title>
<HTA:APPLICATION
APPLICATIONNAME="Computer Hire Form"
BORDER="thin"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
</head>
<script language="VBScript">
' HTA_To_Store_Computer_Data .hta
' https://www.experts-exchange.com/questions/23119848/Computers-inward-outward-Any-software-which-can-do-this-Or-a-script-to-take-the-input-from-a-HTA-fiule-and-store-on-an-excel-sheet.html
' Global variable to hold the path to the text files
' they are defined here to be global, but are assigned
' values in the Window_OnLoad procedure
strCSVPath = ""
Sub Window_OnLoad
intWidth = 900
intHeight = 700
Me.ResizeTo intWidth, intHeight
Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
' This line gets the path from the currently running directory of this HTA
strCSVPath = Mid(Replace(Replace(docume nt.URL, "file://", ""), "%20", " "), 1, InStrRev(Replace(Replace(d ocument.UR L, "file://", ""), "%20", " "), "\"))
If Right(strTextLogPath, 1) <> "\" Then strTextLogPath = strTextLogPath & "\"
strCSVPath = strCSVPath & "ComputerHire.csv"
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
If objFSO.FileExists(strCSVPa th) = False Then
Set objCSVFile = objFSO.CreateTextFile(strC SVPath, True)
objCSVFile.Write """DC Number"",""Date"",""Asset Tag"",""Monitor"",""CPU"", ""Keyboard "",""Make" ",""Model" ",""Proces sor"",""RA M""," & _
"""HDD1"",""HDD2"",""Flopp y Drive"",""CD-ROM"""
objCSVFile.Close
Set objCSVFile = Nothing
End If
txt_date.Value = Date
End Sub
Sub Default_Buttons
If Window.Event.KeyCode = 13 Then
btn_submit.Click
End If
End Sub
Sub Populate_Model
'MsgBox sel_make.Value
strHTML = "<select size='1' id='sel_model' name='sel_model'>" & VbCrLf
strHTML = strHTML & "<option selected id='sel_model_select' value='sel_model_select'>S elect Model...</option>" & VbCrLf
If sel_make.value = "Dell" Then
strHTML = strHTML & "<option value='Optiplex GX520'>Optiplex GX520</option>" & VbCrLf
strHTML = strHTML & "<option value='Optiplex GX620'>Optiplex GX620</option>" & VbCrLf
ElseIf sel_make.value = "HP" Then
strHTML = strHTML & "<option value='HP Compaq DC5750'>HP Compaq DC5750</option>" & VbCrLf
strHTML = strHTML & "<option value='HP Compaq DC7800'>HP Compaq DC7800</option>" & VbCrLf
End If
strHTML = strHTML & "</select>"
span_sel_model.InnerHTML = strHTML
End Sub
Sub Submit_Form
If txt_dcnumber.Value = "" Then
MsgBox "Please enter a DC Number."
txt_dcnumber.Focus
ElseIf txt_assettag.Value = "" Then
MsgBox "Please enter an Asset Tag."
txt_assettag.Focus
ElseIf txt_monitor.Value = "" Then
MsgBox "Please enter a Monitor."
txt_monitor.Focus
ElseIf txt_cpu.Value = "" Then
MsgBox "Please enter a CPU."
txt_cpu.Focus
ElseIf txt_keyboard.Value = "" Then
MsgBox "Please enter a keyboard."
txt_keyboard.Focus
ElseIf sel_make.Value = "sel_make_select" Then
MsgBox "Please select a Make."
sel_make.Focus
ElseIf sel_model.Value = "sel_model_select" Then
MsgBox "Please select a Model."
sel_model.Focus
ElseIf sel_processor.Value = "sel_processor_select" Then
MsgBox "Please select a Processor."
sel_processor.Focus
ElseIf sel_ram.Value = "sel_ram_select" Then
MsgBox "Please select RAM."
sel_ram.Focus
ElseIf sel_hdd1.Value = "sel_hdd1_select" Then
MsgBox "Please select a HDD1."
sel_hdd1.Focus
ElseIf sel_hdd2.Value = "sel_hdd2_select" Then
MsgBox "Please select a HDD2."
sel_hdd2.Focus
ElseIf sel_floppy.Value = "sel_floppy_select" Then
MsgBox "Please select a Floppy Drive."
sel_floppy.Focus
ElseIf sel_cdrom.Value = "sel_cdrom_select" Then
MsgBox "Please select a CD-ROM Drive."
sel_cdrom.Focus
Else
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Const intForAppending = 8
Set objOutputFile = objFSO.OpenTextFile(strCSV Path, intForAppending, False)
objOutputFile.Write VbCrLf & """" & txt_dcnumber.Value & """,""" & txt_date.Value & """,""" & txt_assettag.Value & """," & _
"""" & txt_monitor.Value & """,""" & txt_cpu.Value & """,""" & txt_keyboard.Value & """,""" & sel_make.Value & """," & _
"""" & sel_model.Value & """,""" & sel_processor.Value & """,""" & sel_ram.Value & """,""" & sel_hdd1.Value & """," & _
"""" & sel_hdd2.Value & """,""" & sel_floppy.Value & """,""" & sel_cdrom.Value & """"
objOutputFile.Close
Set objOutputFile = Nothing
Set objFSO = Nothing
MsgBox "Data stored in " & strCSVPath
'=== Increment the Asset tag ===
boolInteger = False
intPos = 0
While boolInteger = False
intPos = intPos + 1
If intPos > Len(txt_assettag.Value) Then boolInteger = True
strChar = Mid(txt_assettag.Value, intPos, 1)
If IsNumeric(strChar) = True Then boolInteger = True
Wend
If intPos <= Len(txt_assettag.Value) Then
strNumber = Mid(txt_assettag.Value, intPos)
intNumberLength = Len(strNumber)
intNextNumber = Int(strNumber) + 1
'MsgBox Left(txt_assettag.Value, intPos - 1) & String(intNumberLength - Len(intNextNumber), "0") & intNextNumber
strNewTag = Left(txt_assettag.Value, intPos - 1) & String(intNumberLength - Len(intNextNumber), "0") & intNextNumber
txt_assettag.Value = strNewTag
Else
txt_assettag.Value = ""
End If
'==== Clear fields ====
'txt_dcnumber.Value = ""
'txt_monitor.Value = ""
'txt_cpu.Value = ""
'txt_keyboard.Value = ""
'sel_make.Value = "sel_make_select"
'sel_model.Value = "sel_model_select"
'sel_processor.Value = "sel_processor_select"
'sel_ram.Value = "sel_ram_select"
'sel_hdd1.Value = "sel_hdd1_select"
'sel_hdd2.Value = "sel_hdd2_select"
'sel_floppy.Value = "sel_floppy_select"
'sel_cdrom.Value = "sel_cdrom_select"
'window.Close
End If
End Sub
</script>
<body STYLE="font:14 pt arial; color:white;filter:progid: DXImageTra nsform.Mic rosoft.Gra dient
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Bu ttons'>
<table width='90%' height = '100%' align='center' border='0'>
<tr>
<td align='center'>
<h3>Computer Hire Form</h3><br>
</td>
</tr
<tr>
<td align='center'>
<table border="0">
<tr>
<td>
DC Number:
</td>
<td colspan="2">
<input type="text" maxlength="30" size="40" id="txt_dcnumber" name="txt_dcnumber">
</td>
</tr>
<tr>
<td>
Date:
</td>
<td colspan="2">
<input type="text" maxlength="30" size="40" id="txt_date" name="txt_date">
</td>
</tr>
<tr>
<td>
Asset Tag:
</td>
<td colspan="2">
<input type="text" maxlength="30" size="40" id="txt_assettag" name="txt_assettag">
</td>
</tr>
<tr>
<td>
Monitor:
</td>
<td colspan="2">
<input type="text" maxlength="80" size="100" id="txt_monitor" name="txt_monitor">
</td>
</tr>
<tr>
<td>
CPU:
</td>
<td colspan="2">
<input type="text" maxlength="80" size="100" id="txt_cpu" name="txt_cpu">
</td>
</tr>
<tr>
<td>
Keyboard:
</td>
<td colspan="2">
<input type="text" maxlength="80" size="100" id="txt_keyboard" name="txt_keyboard">
</td>
</tr>
<tr>
<td>
<br><br>Configuration:
</td>
</tr>
<tr>
<td>
Make:   
</td>
<td>
<select size="1" id="sel_make" name="sel_make" onchange="vbs:Populate_Mod el">
<option selected id="sel_make_select" value="sel_make_select">Se lect Make...</option>
<option id="sel_make_dell" value="Dell">Dell</option>
<option id="sel_make_hp" value="HP">HP</option>
</select>
</td>
</tr>
<tr>
<td>
Model:   
</td>
<td>
<span id="span_sel_model">
<select size="1" id="sel_model" name="sel_model">
<option selected id="sel_model_select" value="sel_model_select">S elect Model...</option>
</select>
</span>
</td>
</tr>
<tr>
<td>
Processor:   
</td>
<td>
<select size="1" id="sel_processor" name="sel_processor">
<option selected id="sel_processor_select" value="sel_processor_selec t">Select Processor...</option>
<option id="sel_processor_2-8Ghz" value="2.8 Ghz">2.8 Ghz</option>
<option id="sel_processor_3-2Ghz" value="3.2 Ghz">3.2 Ghz</option>
</select>
</td>
</tr>
<tr>
<td>
RAM:   
</td>
<td>
<select size="1" id="sel_ram" name="sel_ram">
<option selected id="sel_ram_select" value="sel_ram_select">Sel ect RAM...</option>
<option id="sel_ram_512Mb" value="512 Mb">512 Mb</option>
<option id="sel_ram_1Gb" value="1 Gb">1 Gb</option>
</select>
</td>
</tr>
<tr>
<td>
HDD1:   
</td>
<td>
<select size="1" id="sel_hdd1" name="sel_hdd1">
<option selected id="sel_hdd1_select" value="sel_hdd1_select">Se lect HDD1...</option>
<option id="sel_hdd1_20Gb" value="20 Gb">20 Gb</option>
<option id="sel_hdd1_40Gb" value="40 Gb">40 Gb</option>
</select>
</td>
</tr>
<tr>
<td>
HDD2:   
</td>
<td>
<select size="1" id="sel_hdd2" name="sel_hdd2">
<option selected id="sel_hdd2_select" value="sel_hdd2_select">Se lect HDD2...</option>
<option id="sel_hdd2_none" value="None">None</option>
<option id="sel_hdd2_20Gb" value="20 Gb">20 Gb</option>
<option id="sel_hdd2_40Gb" value="40 Gb">40 Gb</option>
</select>
</td>
</tr>
<tr>
<td>
Floppy Drive:   
</td>
<td>
<select size="1" id="sel_floppy" name="sel_floppy">
<option selected id="sel_floppy_select" value="sel_floppy_select"> Select Floppy...</option>
<option id="sel_floppy_yes" value="Yes">Yes</option>
<option id="sel_floppy_no" value="No">No</option>
</select>
</td>
</tr>
<tr>
<td>
CD-ROM:   
</td>
<td>
<select size="1" id="sel_cdrom" name="sel_cdrom">
<option selected id="sel_cdrom_select" value="sel_cdrom_select">S elect CD-ROM...</option>
<option id="sel_cdrom_none" value="None">None</option>
<option id="sel_cdrom_52x" value="52X CD-ROM">52X CD-ROM</option>
<option id="sel_cdrom_dvd_rom" value="CD-ROM / DVD-ROM Combo">CD-ROM / DVD-ROM Combo</option>
<option id="sel_cdrom_dvd_dl" value="Dual Layer DVD Burner">Dual Layer DVD Burner</option>
</select>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align='center'>
<br>Please note that all fields are required.
</td>
</tr>
<tr>
<td align='center'>
<input type="button" value="Submit" name="btn_submit" onClick="vbs:Submit_Form"> <br><br>
</td>
</tr>
</table>
</body>
Regards,
Rob.
Also, to another Make, add one to this section:
<select size="1" id="sel_make" name="sel_make" onchange="vbs:Populate_Mod
<option selected id="sel_make_select" value="sel_make_select">Se
<option id="sel_make_dell" value="Dell">Dell</option>
<option id="sel_make_hp" value="HP">HP</option>
</select>
for example, add:
<option id="sel_make_toshiba" value="Toshiba">Toshiba</o
and then to add models for that make (or add to other makes), add that to here
Sub Populate_Model
'MsgBox sel_make.Value
strHTML = "<select size='1' id='sel_model' name='sel_model'>" & VbCrLf
strHTML = strHTML & "<option selected id='sel_model_select' value='sel_model_select'>S
If sel_make.value = "Dell" Then
strHTML = strHTML & "<option value='Optiplex GX520'>Optiplex GX520</option>" & VbCrLf
strHTML = strHTML & "<option value='Optiplex GX620'>Optiplex GX620</option>" & VbCrLf
ElseIf sel_make.value = "HP" Then
strHTML = strHTML & "<option value='HP Compaq DC5750'>HP Compaq DC5750</option>" & VbCrLf
strHTML = strHTML & "<option value='HP Compaq DC7800'>HP Compaq DC7800</option>" & VbCrLf
End If
strHTML = strHTML & "</select>"
span_sel_model.InnerHTML = strHTML
End Sub
for example, add another make and models:
ElseIf sel_make.value = "Toshiba" Then
strHTML = strHTML & "<option value='Toshiba Satellite Pro 6100'>Toshiba Satellite Pro 6100</option>" & VbCrLf
strHTML = strHTML & "<option value='Toshiba Satellite Pro P200'>Toshiba Satellite Pro P200</option>" & VbCrLf
That should do it.
<head>
<title>Computer Hire Form</title>
<HTA:APPLICATION
APPLICATIONNAME="Computer Hire Form"
BORDER="thin"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
</head>
<script language="VBScript">
' HTA_To_Store_Computer_Data
' https://www.experts-exchange.com/questions/23119848/Computers-inward-outward-Any-software-which-can-do-this-Or-a-script-to-take-the-input-from-a-HTA-fiule-and-store-on-an-excel-sheet.html
' Global variable to hold the path to the text files
' they are defined here to be global, but are assigned
' values in the Window_OnLoad procedure
strCSVPath = ""
Sub Window_OnLoad
intWidth = 900
intHeight = 700
Me.ResizeTo intWidth, intHeight
Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
' This line gets the path from the currently running directory of this HTA
strCSVPath = Mid(Replace(Replace(docume
If Right(strTextLogPath, 1) <> "\" Then strTextLogPath = strTextLogPath & "\"
strCSVPath = strCSVPath & "ComputerHire.csv"
Set objFSO = CreateObject("Scripting.Fi
If objFSO.FileExists(strCSVPa
Set objCSVFile = objFSO.CreateTextFile(strC
objCSVFile.Write """DC Number"",""Date"",""Asset Tag"",""Monitor"",""CPU"",
"""HDD1"",""HDD2"",""Flopp
objCSVFile.Close
Set objCSVFile = Nothing
End If
txt_date.Value = Date
End Sub
Sub Default_Buttons
If Window.Event.KeyCode = 13 Then
btn_submit.Click
End If
End Sub
Sub Populate_Model
'MsgBox sel_make.Value
strHTML = "<select size='1' id='sel_model' name='sel_model'>" & VbCrLf
strHTML = strHTML & "<option selected id='sel_model_select' value='sel_model_select'>S
If sel_make.value = "Dell" Then
strHTML = strHTML & "<option value='Optiplex GX520'>Optiplex GX520</option>" & VbCrLf
strHTML = strHTML & "<option value='Optiplex GX620'>Optiplex GX620</option>" & VbCrLf
ElseIf sel_make.value = "HP" Then
strHTML = strHTML & "<option value='HP Compaq DC5750'>HP Compaq DC5750</option>" & VbCrLf
strHTML = strHTML & "<option value='HP Compaq DC7800'>HP Compaq DC7800</option>" & VbCrLf
End If
strHTML = strHTML & "</select>"
span_sel_model.InnerHTML = strHTML
End Sub
Sub Submit_Form
If txt_dcnumber.Value = "" Then
MsgBox "Please enter a DC Number."
txt_dcnumber.Focus
ElseIf txt_assettag.Value = "" Then
MsgBox "Please enter an Asset Tag."
txt_assettag.Focus
ElseIf txt_monitor.Value = "" Then
MsgBox "Please enter a Monitor."
txt_monitor.Focus
ElseIf txt_cpu.Value = "" Then
MsgBox "Please enter a CPU."
txt_cpu.Focus
ElseIf txt_keyboard.Value = "" Then
MsgBox "Please enter a keyboard."
txt_keyboard.Focus
ElseIf sel_make.Value = "sel_make_select" Then
MsgBox "Please select a Make."
sel_make.Focus
ElseIf sel_model.Value = "sel_model_select" Then
MsgBox "Please select a Model."
sel_model.Focus
ElseIf sel_processor.Value = "sel_processor_select" Then
MsgBox "Please select a Processor."
sel_processor.Focus
ElseIf sel_ram.Value = "sel_ram_select" Then
MsgBox "Please select RAM."
sel_ram.Focus
ElseIf sel_hdd1.Value = "sel_hdd1_select" Then
MsgBox "Please select a HDD1."
sel_hdd1.Focus
ElseIf sel_hdd2.Value = "sel_hdd2_select" Then
MsgBox "Please select a HDD2."
sel_hdd2.Focus
ElseIf sel_floppy.Value = "sel_floppy_select" Then
MsgBox "Please select a Floppy Drive."
sel_floppy.Focus
ElseIf sel_cdrom.Value = "sel_cdrom_select" Then
MsgBox "Please select a CD-ROM Drive."
sel_cdrom.Focus
Else
Set objFSO = CreateObject("Scripting.Fi
Const intForAppending = 8
Set objOutputFile = objFSO.OpenTextFile(strCSV
objOutputFile.Write VbCrLf & """" & txt_dcnumber.Value & """,""" & txt_date.Value & """,""" & txt_assettag.Value & """," & _
"""" & txt_monitor.Value & """,""" & txt_cpu.Value & """,""" & txt_keyboard.Value & """,""" & sel_make.Value & """," & _
"""" & sel_model.Value & """,""" & sel_processor.Value & """,""" & sel_ram.Value & """,""" & sel_hdd1.Value & """," & _
"""" & sel_hdd2.Value & """,""" & sel_floppy.Value & """,""" & sel_cdrom.Value & """"
objOutputFile.Close
Set objOutputFile = Nothing
Set objFSO = Nothing
MsgBox "Data stored in " & strCSVPath
'=== Increment the Asset tag ===
boolInteger = False
intPos = 0
While boolInteger = False
intPos = intPos + 1
If intPos > Len(txt_assettag.Value) Then boolInteger = True
strChar = Mid(txt_assettag.Value, intPos, 1)
If IsNumeric(strChar) = True Then boolInteger = True
Wend
If intPos <= Len(txt_assettag.Value) Then
strNumber = Mid(txt_assettag.Value, intPos)
intNumberLength = Len(strNumber)
intNextNumber = Int(strNumber) + 1
'MsgBox Left(txt_assettag.Value, intPos - 1) & String(intNumberLength - Len(intNextNumber), "0") & intNextNumber
strNewTag = Left(txt_assettag.Value, intPos - 1) & String(intNumberLength - Len(intNextNumber), "0") & intNextNumber
txt_assettag.Value = strNewTag
Else
txt_assettag.Value = ""
End If
'==== Clear fields ====
'txt_dcnumber.Value = ""
'txt_monitor.Value = ""
'txt_cpu.Value = ""
'txt_keyboard.Value = ""
'sel_make.Value = "sel_make_select"
'sel_model.Value = "sel_model_select"
'sel_processor.Value = "sel_processor_select"
'sel_ram.Value = "sel_ram_select"
'sel_hdd1.Value = "sel_hdd1_select"
'sel_hdd2.Value = "sel_hdd2_select"
'sel_floppy.Value = "sel_floppy_select"
'sel_cdrom.Value = "sel_cdrom_select"
'window.Close
End If
End Sub
</script>
<body STYLE="font:14 pt arial; color:white;filter:progid:
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Bu
<table width='90%' height = '100%' align='center' border='0'>
<tr>
<td align='center'>
<h3>Computer Hire Form</h3><br>
</td>
</tr
<tr>
<td align='center'>
<table border="0">
<tr>
<td>
DC Number:
</td>
<td colspan="2">
<input type="text" maxlength="30" size="40" id="txt_dcnumber" name="txt_dcnumber">
</td>
</tr>
<tr>
<td>
Date:
</td>
<td colspan="2">
<input type="text" maxlength="30" size="40" id="txt_date" name="txt_date">
</td>
</tr>
<tr>
<td>
Asset Tag:
</td>
<td colspan="2">
<input type="text" maxlength="30" size="40" id="txt_assettag" name="txt_assettag">
</td>
</tr>
<tr>
<td>
Monitor:
</td>
<td colspan="2">
<input type="text" maxlength="80" size="100" id="txt_monitor" name="txt_monitor">
</td>
</tr>
<tr>
<td>
CPU:
</td>
<td colspan="2">
<input type="text" maxlength="80" size="100" id="txt_cpu" name="txt_cpu">
</td>
</tr>
<tr>
<td>
Keyboard:
</td>
<td colspan="2">
<input type="text" maxlength="80" size="100" id="txt_keyboard" name="txt_keyboard">
</td>
</tr>
<tr>
<td>
<br><br>Configuration:
</td>
</tr>
<tr>
<td>
Make:   
</td>
<td>
<select size="1" id="sel_make" name="sel_make" onchange="vbs:Populate_Mod
<option selected id="sel_make_select" value="sel_make_select">Se
<option id="sel_make_dell" value="Dell">Dell</option>
<option id="sel_make_hp" value="HP">HP</option>
</select>
</td>
</tr>
<tr>
<td>
Model:   
</td>
<td>
<span id="span_sel_model">
<select size="1" id="sel_model" name="sel_model">
<option selected id="sel_model_select" value="sel_model_select">S
</select>
</span>
</td>
</tr>
<tr>
<td>
Processor:   
</td>
<td>
<select size="1" id="sel_processor" name="sel_processor">
<option selected id="sel_processor_select" value="sel_processor_selec
<option id="sel_processor_2-8Ghz" value="2.8 Ghz">2.8 Ghz</option>
<option id="sel_processor_3-2Ghz" value="3.2 Ghz">3.2 Ghz</option>
</select>
</td>
</tr>
<tr>
<td>
RAM:   
</td>
<td>
<select size="1" id="sel_ram" name="sel_ram">
<option selected id="sel_ram_select" value="sel_ram_select">Sel
<option id="sel_ram_512Mb" value="512 Mb">512 Mb</option>
<option id="sel_ram_1Gb" value="1 Gb">1 Gb</option>
</select>
</td>
</tr>
<tr>
<td>
HDD1:   
</td>
<td>
<select size="1" id="sel_hdd1" name="sel_hdd1">
<option selected id="sel_hdd1_select" value="sel_hdd1_select">Se
<option id="sel_hdd1_20Gb" value="20 Gb">20 Gb</option>
<option id="sel_hdd1_40Gb" value="40 Gb">40 Gb</option>
</select>
</td>
</tr>
<tr>
<td>
HDD2:   
</td>
<td>
<select size="1" id="sel_hdd2" name="sel_hdd2">
<option selected id="sel_hdd2_select" value="sel_hdd2_select">Se
<option id="sel_hdd2_none" value="None">None</option>
<option id="sel_hdd2_20Gb" value="20 Gb">20 Gb</option>
<option id="sel_hdd2_40Gb" value="40 Gb">40 Gb</option>
</select>
</td>
</tr>
<tr>
<td>
Floppy Drive:   
</td>
<td>
<select size="1" id="sel_floppy" name="sel_floppy">
<option selected id="sel_floppy_select" value="sel_floppy_select">
<option id="sel_floppy_yes" value="Yes">Yes</option>
<option id="sel_floppy_no" value="No">No</option>
</select>
</td>
</tr>
<tr>
<td>
CD-ROM:   
</td>
<td>
<select size="1" id="sel_cdrom" name="sel_cdrom">
<option selected id="sel_cdrom_select" value="sel_cdrom_select">S
<option id="sel_cdrom_none" value="None">None</option>
<option id="sel_cdrom_52x" value="52X CD-ROM">52X CD-ROM</option>
<option id="sel_cdrom_dvd_rom" value="CD-ROM / DVD-ROM Combo">CD-ROM / DVD-ROM Combo</option>
<option id="sel_cdrom_dvd_dl" value="Dual Layer DVD Burner">Dual Layer DVD Burner</option>
</select>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align='center'>
<br>Please note that all fields are required.
</td>
</tr>
<tr>
<td align='center'>
<input type="button" value="Submit" name="btn_submit" onClick="vbs:Submit_Form">
</td>
</tr>
</table>
</body>
Regards,
Rob.
If you use an HTA file then that should be all you need. Of course this will depend on security settings in the browser but an HTA file is usually allowed to do more. It can certainly read the input and usually can create a text file too. I will show you how to do the csv file.
' use code to get the form values and create a variable strCSV with the info setup comma separated
Dim objFSO, objFile
Set objFSO = CreateObject("Scripting.Fi
Set objFile = objFSO.CreateTextFile("fil
objFile.Write strCSV
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
That should give you the basic idea. If you need help making the variable with the comma separated data from the form then provide specifics or an example of the form. Let me know if you have any questions or need more information.
b0lsc0tt