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,configuration etc and then store the data to an csv or excel file.Or is there a software which can do this.

Regards
Sharath
LVL 11
bsharathAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

b0lsc0ttIT ManagerCommented:
bsharath,

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.FileSystemObject")
Set objFile = objFSO.CreateTextFile("filename.csv")
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
0
RobSampsonCommented:
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(document.URL, "file://", ""), "%20", " "), 1, InStrRev(Replace(Replace(document.URL, "file://", ""), "%20", " "), "\"))

      If Right(strTextLogPath, 1) <> "\" Then strTextLogPath = strTextLogPath & "\"
      strCSVPath = strCSVPath & "ComputerHire.csv"
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      If objFSO.FileExists(strCSVPath) = False Then
            Set objCSVFile = objFSO.CreateTextFile(strCSVPath, 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.FileSystemObject")
            Const intForAppending = 8
            Set objOutputFile = objFSO.OpenTextFile(strCSVPath, 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:DXImageTransform.Microsoft.Gradient
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Buttons'>
      <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.
0
bsharathAuthor Commented:
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...
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

bsharathAuthor Commented:
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..

0
bsharathAuthor Commented:
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
0
bsharathAuthor Commented:
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
0
RobSampsonCommented:
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
' http://www.experts-exchange.com/Programming/Languages/Q_23119848.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(document.URL, "file://", ""), "%20", " "), 1, InStrRev(Replace(Replace(document.URL, "file://", ""), "%20", " "), "\"))

      If Right(strTextLogPath, 1) <> "\" Then strTextLogPath = strTextLogPath & "\"
      strCSVPath = strCSVPath & "ComputerHire.csv"
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      If objFSO.FileExists(strCSVPath) = False Then
            Set objCSVFile = objFSO.CreateTextFile(strCSVPath, True)
            objCSVFile.Write """DC Number"",""Date"",""Asset Tag"",""Monitor"",""CPU"",""Keyboard"",""Make"",""Model"",""Processor"",""RAM""," & _
                  """HDD1"",""HDD2"",""Floppy 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'>Select 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.FileSystemObject")
            Const intForAppending = 8
            Set objOutputFile = objFSO.OpenTextFile(strCSVPath, 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:DXImageTransform.Microsoft.Gradient
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Buttons'>
      <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:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_make" name="sel_make" onchange="vbs:Populate_Model">
                                                <option selected id="sel_make_select" value="sel_make_select">Select Make...</option>
                                                <option id="sel_make_dell" value="sel_make_dell">Dell</option>
                                                <option id="sel_make_hp" value="sel_make_hp">HP</option>
                                          </select>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Model:&nbsp&nbsp&nbsp
                                    </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">Select Model...</option>
                                                </select>
                                          </span>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Processor:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_processor" name="sel_processor">
                                                <option selected id="sel_processor_select" value="sel_processor_select">Select Processor...</option>
                                                <option id="sel_processor_2-8Ghz" value="sel_processor_2-8Ghz">2.8 Ghz</option>
                                                <option id="sel_processor_3-2Ghz" value="sel_processor_3-2Ghz">3.2 Ghz</option>
                                          </select>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          RAM:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_ram" name="sel_ram">
                                                <option selected id="sel_ram_select" value="sel_ram_select">Select RAM...</option>
                                                <option id="sel_ram_512Mb" value="sel_ram_512Mb">512Mb</option>
                                                <option id="sel_ram_1Gb" value="sel_ram_1Gb">1Gb</option>
                                          </select>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          HDD1:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_hdd1" name="sel_hdd1">
                                                <option selected id="sel_hdd1_select" value="sel_hdd1_select">Select 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:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_hdd2" name="sel_hdd2">
                                                <option selected id="sel_hdd2_select" value="sel_hdd2_select">Select 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:&nbsp&nbsp&nbsp
                                    </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:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_cdrom" name="sel_cdrom">
                                                <option selected id="sel_cdrom_select" value="sel_cdrom_select">Select CD-ROM...</option>
                                                <option id="sel_cdrom_none" value="sel_cdrom_none">None</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">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.
0
bsharathAuthor Commented:
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.

0
bsharathAuthor Commented:
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...
0
RobSampsonCommented:
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
' http://www.experts-exchange.com/Programming/Languages/Q_23119848.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(document.URL, "file://", ""), "%20", " "), 1, InStrRev(Replace(Replace(document.URL, "file://", ""), "%20", " "), "\"))

      If Right(strTextLogPath, 1) <> "\" Then strTextLogPath = strTextLogPath & "\"
      strCSVPath = strCSVPath & "ComputerHire.csv"
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      If objFSO.FileExists(strCSVPath) = False Then
            Set objCSVFile = objFSO.CreateTextFile(strCSVPath, True)
            objCSVFile.Write """DC Number"",""Date"",""Asset Tag"",""Monitor"",""CPU"",""Keyboard"",""Make"",""Model"",""Processor"",""RAM""," & _
                  """HDD1"",""HDD2"",""Floppy 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'>Select 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.FileSystemObject")
            Const intForAppending = 8
            Set objOutputFile = objFSO.OpenTextFile(strCSVPath, 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:DXImageTransform.Microsoft.Gradient
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Buttons'>
      <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:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_make" name="sel_make" onchange="vbs:Populate_Model">
                                                <option selected id="sel_make_select" value="sel_make_select">Select Make...</option>
                                                <option id="sel_make_dell" value="sel_make_dell">Dell</option>
                                                <option id="sel_make_hp" value="sel_make_hp">HP</option>
                                          </select>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Model:&nbsp&nbsp&nbsp
                                    </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">Select Model...</option>
                                                </select>
                                          </span>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Processor:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_processor" name="sel_processor">
                                                <option selected id="sel_processor_select" value="sel_processor_select">Select Processor...</option>
                                                <option id="sel_processor_2-8Ghz" value="sel_processor_2-8Ghz">2.8 Ghz</option>
                                                <option id="sel_processor_3-2Ghz" value="sel_processor_3-2Ghz">3.2 Ghz</option>
                                          </select>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          RAM:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_ram" name="sel_ram">
                                                <option selected id="sel_ram_select" value="sel_ram_select">Select RAM...</option>
                                                <option id="sel_ram_512Mb" value="sel_ram_512Mb">512Mb</option>
                                                <option id="sel_ram_1Gb" value="sel_ram_1Gb">1Gb</option>
                                          </select>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          HDD1:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_hdd1" name="sel_hdd1">
                                                <option selected id="sel_hdd1_select" value="sel_hdd1_select">Select 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:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_hdd2" name="sel_hdd2">
                                                <option selected id="sel_hdd2_select" value="sel_hdd2_select">Select 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:&nbsp&nbsp&nbsp
                                    </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:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_cdrom" name="sel_cdrom">
                                                <option selected id="sel_cdrom_select" value="sel_cdrom_select">Select CD-ROM...</option>
                                                <option id="sel_cdrom_none" value="sel_cdrom_none">None</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">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.
0
bsharathAuthor Commented:
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  
---------------------------
0
RobSampsonCommented:
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.
0
bsharathAuthor Commented:
I get this error...

ScreenShot030.jpg
0
RobSampsonCommented:
Here's the whole code....seems to work for me....


<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
' http://www.experts-exchange.com/Programming/Languages/Q_23119848.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(document.URL, "file://", ""), "%20", " "), 1, InStrRev(Replace(Replace(document.URL, "file://", ""), "%20", " "), "\"))

      If Right(strTextLogPath, 1) <> "\" Then strTextLogPath = strTextLogPath & "\"
      strCSVPath = strCSVPath & "ComputerHire.csv"
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      If objFSO.FileExists(strCSVPath) = False Then
            Set objCSVFile = objFSO.CreateTextFile(strCSVPath, True)
            objCSVFile.Write """DC Number"",""Date"",""Asset Tag"",""Monitor"",""CPU"",""Keyboard"",""Make"",""Model"",""Processor"",""RAM""," & _
                  """HDD1"",""HDD2"",""Floppy 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'>Select 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.FileSystemObject")
            Const intForAppending = 8
            Set objOutputFile = objFSO.OpenTextFile(strCSVPath, 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:DXImageTransform.Microsoft.Gradient
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Buttons'>
      <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:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_make" name="sel_make" onchange="vbs:Populate_Model">
                                                <option selected id="sel_make_select" value="sel_make_select">Select Make...</option>
                                                <option id="sel_make_dell" value="sel_make_dell">Dell</option>
                                                <option id="sel_make_hp" value="sel_make_hp">HP</option>
                                          </select>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Model:&nbsp&nbsp&nbsp
                                    </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">Select Model...</option>
                                                </select>
                                          </span>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Processor:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_processor" name="sel_processor">
                                                <option selected id="sel_processor_select" value="sel_processor_select">Select Processor...</option>
                                                <option id="sel_processor_2-8Ghz" value="sel_processor_2-8Ghz">2.8 Ghz</option>
                                                <option id="sel_processor_3-2Ghz" value="sel_processor_3-2Ghz">3.2 Ghz</option>
                                          </select>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          RAM:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_ram" name="sel_ram">
                                                <option selected id="sel_ram_select" value="sel_ram_select">Select RAM...</option>
                                                <option id="sel_ram_512Mb" value="sel_ram_512Mb">512Mb</option>
                                                <option id="sel_ram_1Gb" value="sel_ram_1Gb">1Gb</option>
                                          </select>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          HDD1:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_hdd1" name="sel_hdd1">
                                                <option selected id="sel_hdd1_select" value="sel_hdd1_select">Select 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:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_hdd2" name="sel_hdd2">
                                                <option selected id="sel_hdd2_select" value="sel_hdd2_select">Select 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:&nbsp&nbsp&nbsp
                                    </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:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_cdrom" name="sel_cdrom">
                                                <option selected id="sel_cdrom_select" value="sel_cdrom_select">Select CD-ROM...</option>
                                                <option id="sel_cdrom_none" value="sel_cdrom_none">None</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">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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bsharathAuthor Commented:
Thanks a lot Rob....
0
bsharathAuthor Commented:
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?
0
RobSampsonCommented:
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_Model">
      <option selected id="sel_make_select" value="sel_make_select">Select 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</option>

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'>Select 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
' http://www.experts-exchange.com/Programming/Languages/Q_23119848.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(document.URL, "file://", ""), "%20", " "), 1, InStrRev(Replace(Replace(document.URL, "file://", ""), "%20", " "), "\"))

      If Right(strTextLogPath, 1) <> "\" Then strTextLogPath = strTextLogPath & "\"
      strCSVPath = strCSVPath & "ComputerHire.csv"
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      If objFSO.FileExists(strCSVPath) = False Then
            Set objCSVFile = objFSO.CreateTextFile(strCSVPath, True)
            objCSVFile.Write """DC Number"",""Date"",""Asset Tag"",""Monitor"",""CPU"",""Keyboard"",""Make"",""Model"",""Processor"",""RAM""," & _
                  """HDD1"",""HDD2"",""Floppy 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'>Select 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.FileSystemObject")
            Const intForAppending = 8
            Set objOutputFile = objFSO.OpenTextFile(strCSVPath, 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:DXImageTransform.Microsoft.Gradient
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Buttons'>
      <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:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_make" name="sel_make" onchange="vbs:Populate_Model">
                                                <option selected id="sel_make_select" value="sel_make_select">Select 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:&nbsp&nbsp&nbsp
                                    </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">Select Model...</option>
                                                </select>
                                          </span>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Processor:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_processor" name="sel_processor">
                                                <option selected id="sel_processor_select" value="sel_processor_select">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:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_ram" name="sel_ram">
                                                <option selected id="sel_ram_select" value="sel_ram_select">Select 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:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_hdd1" name="sel_hdd1">
                                                <option selected id="sel_hdd1_select" value="sel_hdd1_select">Select 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:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_hdd2" name="sel_hdd2">
                                                <option selected id="sel_hdd2_select" value="sel_hdd2_select">Select 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:&nbsp&nbsp&nbsp
                                    </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:&nbsp&nbsp&nbsp
                                    </td>
                                    <td>
                                          <select size="1" id="sel_cdrom" name="sel_cdrom">
                                                <option selected id="sel_cdrom_select" value="sel_cdrom_select">Select 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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.