I have never worked with an hta file before so there is probably a much better way of doing the but this seems to allow you to delete the proper row.
I made updates to the doAddRow and deleteRow methods.
Code:
<html>
<head>
<title>Execution Alpha</title>
<HTA:APPLICATION ID="oHTA"
APPLICATIONNAME="StockPredictions"
Border = "thin"
Borderstyle = "complex"
>
<script language="VBScript">
count=1 'setting counter
''''''''''''''''''''''''Window Sizing'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub StartUp()
Dim x,y
x = (window.screen.width - 500) / 2
y = (window.screen.height - 300) / 2
If x < 0 Then x = 0
If y < 0 Then y = 0
window.resizeTo 500,300
window.moveTo x,y
End Sub
StartUp
''''''''''''''''''''''''Table set up'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub checkEnter()
if window.event.keyCode = 13 then
runTogether()
end if
end sub
sub runTogether()
confirm()
doAddRow()
writeToFile()
start()
end sub
sub confirm()
if Prediction(0).checked then
Selection = "Up"
end if
if Prediction(1).Checked then
Selection = "Down"
end if
Dim oWNet : Set oWNet = CreateObject("WScript.Network")''''''''''''''''''''''' get username''''''''''''''''''''''''''''''''''''''''''''''
'if Symbol.value <> "" then
' msgBox "You entered " & Symbol.value & " and predict that the stock will go " & Selection, 64, "Input" '''' test reciept of input
'end if
end sub
Sub doAddRow()
if Prediction(0).checked then
Selection = "Up"
end if
if Prediction(1).Checked then
Selection = "Down"
end if
Dim strButton
strButton = "<input name = 'endCOUNT' type = 'button' value = 'End' onclick = 'deleteRow(COUNT)'/>"
strButton = Replace(strButton, "COUNT", count)
if Symbol.value <> "" then
Dim oTbl, oRow, oCell
Set oTbl=document.getElementById("mytable")
Set oRow = oTbl.insertRow
Set oCell = oRow.insertCell
oCell.innerHTML= Symbol.value
Set oCell = oRow.insertCell
oCell.innerHTML =Selection
Set oCell = oRow.insertCell
oCell.innerHTML= Time()
Set oCell = oRow.insertCell
oCell.innerHTML= DropDown2.Value
Set oCell = oRow.insertCell
oCell.innerHTML= strButton
else
msgBox "You did not enter a symbol!"
end if
count = count+1
End sub
''''''''''''''''''''''''Delete selections'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub deleteRow(row)
Dim oTbl, oRow
Set oTbl=document.getElementById("mytable")
Dim cinput
Dim indx
indx = 1
set cinput=document.getElementsByTagName("input")
for i=0 to cinput.length-1
if cinput(i).type="button" then
if instr(cinput(i).name, "end") then
indx = indx + 1
if cinput(i).name = "end" & row then
exit for
end if
end if
end if
next
if indx > 1 then
oTbl.deleteRow(indx)
end if
End Sub
''''''''''''''''''''''''Start and End''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
dim startEnd
startEnd = "Start"
sub start()
startEnd = "Start"
end sub
'sub end()
' startEnd = "End"
'end sub
''''''''''''''''''''''''Write to file''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub writeToFile()
if Prediction(0).checked then
Selection = "Up"
end if
if Prediction(1).Checked then
Selection = "Down"
end if
Set objFSO = CreateObject("Scripting.FileSystemObject")
filename = "C:\Documents and Settings\Mark\Desktop\pred.csv"
If objFSO.FileExists(filename) Then
Dim oWNet : Set oWNet = CreateObject("WScript.Network")
Set objFile = objFSO.OpenTextFile(filename, 8)
strLine = oWNet.UserName & " , " & startEnd & " , " & Symbol.value & " , " & Selection & " , " & Now() & " , " & DropDown2.Value
objFile.WriteLine strLine
objFile.Close
end if
end sub
''''''''''''''''''''''''GUI''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
</script>
<style>
BODY {
background-color: buttonface;
margin-top: 10px;`
margin-left: 20px;
margin-right: 20px;
margin-bottom: 5px;
font-family: arial,sans-serif;
font-size: 10pt;
}
.button {
width: 91px;
height: 25px;
font-family: arial,sans-serif;
font-size: 8pt;
}
td {
font-family: arial,sans-serif;
font-size: 10pt;
}
#scroll {
height:100%;
overflow:auto;
}
SELECT.FixedWidth {
width: 17em; /* maybe use px for pixels or pt for points here */
}
</style>
</head>
<body bgcolor="#FFFFFF">
<left>
<table align="center" width="100%" id="mytable2" border='1'>
<tr>
<td>Symbol</td><td>Direction</td><td>Rationale</tr>
<tr>
<TD> <input name="Symbol" type="text" id="Symbol" onKeyPress = "checkEnter()" /></TD>
<TD> <input checked name = "Prediction" type = "radio" value = "0"> Up
<input name = "Prediction" type = "radio" value = "1"> Down
<TD>
<select size="1" name="DropDown2">
<option value="Market Flows">Market Flows     </option>
<option value="Directional View">Directional View</option>
</select>
</table>
<center>
<br>
<TABLE>
<TR>
<INPUT TYPE="button" value="Enter" onClick = "runTogether()">
</TABLE>
<p>
<b>Open calls</b>
<table width = "100%" id="mytable" border='1'>
<tr><td>Symbol</td><td>Direction</td><td>Time</td><td>Rationale</td><td>End</td></tr>
<tr>
</table>
</body>
</html>