I am writing data to a CSV file and I'm a little lost with this script. I borrowed this script from an old form from work and would like to modify two things. Please take a look at my issues and help come up with a solution.
If I fill out the form 3 times this is currently what I get written into a CSV:
Rob,6/19/2010,4:59:22 PM,1,2,3,4,5,6,7,8,9,
Rob,6/19/2010,4:59:24 PM,1,2,3,4,5,6,7,8,9,
Rob,6/19/2010,4:59:26 PM,1,2,3,4,5,6,7,8,9,
Rob = The user account
6/19/2010 4:59:22 PM = Current date and time
The numbers are just fillers in my form for the different textareas and dropdowns
Issue 1: I would like the Date/Time to be seperated.
The output should look something like:
Rob,6/19/2010,4:59:22 PM,1,2,3,4,5,6,7,8,9,
Issue 2: I would like to add a "Header" to my CSV file
If I filled out the form 3 times I would expect the output to look something like this:
Oracle,Date,Time,Box1,Box2,Box3,Box4,Box5,Box6,Box7,Box8,Box9,
Rob,6/19/2010,4:59:22 PM,1,2,3,4,5,6,7,8,9,
Rob,6/19/2010,4:59:24 PM,1,2,3,4,5,6,7,8,9,
Rob,6/19/2010,4:59:26 PM,1,2,3,4,5,6,7,8,9,
Here's the script I'm using...
<meta name="vs_defaultClientScript" content=VBScript>
<HTA:APPLICATION
ID= "Tier 2 Tracker"
VERSION= "0.1a"
APPLICATIONNAME= "Tier 2 Tracking Form"
BORDER= "THIN"
CAPTION= "yes"
SHOWINTASKBAR= "yes"
MAXIMIZEBUTTON= "no"
INNERBORDER= "NO"
SINGLEINSTANCE= "yes"
SYSMENU= "yes"
SELECTION= "NO"
SCROLL= "no"
STATUS= "YES"
>
<script id="clientEventHandlersVBS" language="VBScript">
Sub Find_User
set e = CreateObject("WScript.Network")
SPID.InnerHTML = e.UserName
MyDateTime.InnerHTML = Now
End Sub
Sub Write_CSV
Incomplete = 0
WriteRow = ""
WriteRow = SPID.innerText & ","
WriteTemp = MyDateTime.innerText
WriteRow = Writerow & WriteTemp & ","
on error resume next
MyNumber = 1
do until MyNumber = 800
Pull_Down_Name = "r" & MyNumber
WriteRow = Writerow & replace(trim(Document.SurveyForm.Elements(Pull_Down_Name).Value),",",";") & ","
MyNumber = MyNumber +1
if err.number = 0 then
if len(Document.SurveyForm.Elements(Pull_Down_Name).Value) < 1 then Incomplete = Incomplete + 1
end if
err.clear
loop
on error goto 0
If Incomplete > 0then
Msgbox "Please fill in all text boxes and select a response for every question and click SUBMIT again."
'msgbox Incomplete
else
WriteRow = replace(WriteRow,chr(13)," ")
WriteRow = replace(WriteRow,chr(10)," ")
WriteRow = trim(WriteRow)
MyFullFileName = "C:\Users\robertjsadler\Documents\Stream\CoC\Data\CloudyOrClear.csv"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(MyFullFileName,8,true,0)
objFile.WriteLine WriteRow
objFile.Close
SurveyForm.reset
end if
end sub
</script>
Please help.
Thank you,
Rob
If I fill out the form 3 times this is currently what I get written into a CSV:
Rob,6/19/2010,4:59:22 PM,1,2,3,4,5,6,7,8,9,
Rob,6/19/2010,4:59:24 PM,1,2,3,4,5,6,7,8,9,
Rob,6/19/2010,4:59:26 PM,1,2,3,4,5,6,7,8,9,
Rob = The user account
6/19/2010 4:59:22 PM = Current date and time
The numbers are just fillers in my form for the different textareas and dropdowns
Issue 1: I would like the Date/Time to be seperated.
The output should look something like:
Rob,6/19/2010,4:59:22 PM,1,2,3,4,5,6,7,8,9,
Issue 2: I would like to add a "Header" to my CSV file
If I filled out the form 3 times I would expect the output to look something like this:
Oracle,Date,Time,Box1,Box2,Box3,Box4,Box5,Box6,Box7,Box8,Box9,
Rob,6/19/2010,4:59:22 PM,1,2,3,4,5,6,7,8,9,
Rob,6/19/2010,4:59:24 PM,1,2,3,4,5,6,7,8,9,
Rob,6/19/2010,4:59:26 PM,1,2,3,4,5,6,7,8,9,
Here's the script I'm using...
<meta name="vs_defaultClientScript" content=VBScript>
<HTA:APPLICATION
ID= "Tier 2 Tracker"
VERSION= "0.1a"
APPLICATIONNAME= "Tier 2 Tracking Form"
BORDER= "THIN"
CAPTION= "yes"
SHOWINTASKBAR= "yes"
MAXIMIZEBUTTON= "no"
INNERBORDER= "NO"
SINGLEINSTANCE= "yes"
SYSMENU= "yes"
SELECTION= "NO"
SCROLL= "no"
STATUS= "YES"
>
<script id="clientEventHandlersVBS" language="VBScript">
Sub Find_User
set e = CreateObject("WScript.Network")
SPID.InnerHTML = e.UserName
MyDateTime.InnerHTML = Now
End Sub
Sub Write_CSV
Incomplete = 0
WriteRow = ""
WriteRow = SPID.innerText & ","
WriteTemp = MyDateTime.innerText
WriteRow = Writerow & WriteTemp & ","
on error resume next
MyNumber = 1
do until MyNumber = 800
Pull_Down_Name = "r" & MyNumber
WriteRow = Writerow & replace(trim(Document.SurveyForm.Elements(Pull_Down_Name).Value),",",";") & ","
MyNumber = MyNumber +1
if err.number = 0 then
if len(Document.SurveyForm.Elements(Pull_Down_Name).Value) < 1 then Incomplete = Incomplete + 1
end if
err.clear
loop
on error goto 0
If Incomplete > 0then
Msgbox "Please fill in all text boxes and select a response for every question and click SUBMIT again."
'msgbox Incomplete
else
WriteRow = replace(WriteRow,chr(13)," ")
WriteRow = replace(WriteRow,chr(10)," ")
WriteRow = trim(WriteRow)
MyFullFileName = "C:\Users\robertjsadler\Documents\Stream\CoC\Data\CloudyOrClear.csv"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(MyFullFileName,8,true,0)
objFile.WriteLine WriteRow
objFile.Close
SurveyForm.reset
end if
end sub
</script>
Please help.
Thank you,
Rob