I have created a simple form that sends data to an Excel file with an array.
Everything works great except check boxes. What I would like is if the checkbox is "checked" it will post its value into the Excel document. Currently the value assigned for the box (checked) is always pasted no matter if it is checked or not. I am unsure what code is needed for the arr(6).
<script>
function PrintFunction() {
window.print();
}
</script>
<script type="text/vbscript">
function test()
dim oApp, oWB, arr
set oApp = CreateObject("Excel.Application")
oApp.visible=false
set wb = oApp.Workbooks.Open("C:\(PATH TO DB)\DB.xls",,,,"password")
redim arr(6)
arr(0) = Date()
arr(1) = Form1.text1.Value
arr(2) = Time()
arr(3) = Form1.text2.Value
arr(4) = Form1.text3.Value
arr(5) = Form1.text4.Value
arr(6) = Form1.text5.Value <---Need help with this value
with wb.sheets("Data").cells(1,1).currentregion
.offset(.rows.count,0).resize(1).value = arr
end with
wb.close true
x=msgbox("Submitted." ,64, "Thank you.")
window.close()
end function
</script>
</head>
<body oncontextmenu="return false;">
<form name="Form1">
<table border="0" style="width:700px;">
<td>Date:<input value="mm/dd/yyyy" name="text1" type="text" class="inputbox" size="20" />
<tr>
<td>Time:<input value="00:00 AM/PM" name="text2" type="text" class="inputbox" size="20" /></td>
<tr>
<td>Name:<input name="text3" type="text" class="inputbox" size="23"/></td>
<tr>
<td>Location:<input name="text4" type="text" class="inputbox" size="18" /></td>
<tr>
<td><input type="checkbox" name="text5" value="checked">Checkbox Title</td>
<input type="button" value="Print" class="classname" onclick="PrintFunction()" />
<input type="button" value="Submit" class="classname" onclick="test()" />
</table>
<br>
</form>