Hi everyone,

I would really appreciate some help on this code that I am working on for work.

This code records and investors stock choice, the direction they think it will go, and thier rationale. Once the inputs entered theya re submitted to a table in the lower portion of the HTA, and the data in those rows is then exported to a CSV file.

I am having two problems:

1. In each row in the last coloumn there is an "End" button which, when pushed, I would like to see it delete the row it is contained in. Currently, it only deltes the last row enetered. How would I configure it so that when it is click it deltes the row that it is in?
2. Just as every entry is submitted to a CSV I would like to configure the clicking of the "End" button to submit the data in the row that it is contained in to the CSV file before the row is deleted. How would i go about doing that?

Here is the code for your reference:

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

   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= "<input name = 'end' type = 'button' value = 'End' onclick = 'deleteRow()'/>"
   else
      msgBox "You did not enter a symbol!"
   end if

   count = count+1

End sub 


''''''''''''''''''''''''Delete selections'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Sub deleteRow()

   Dim oTbl, oRow
   Set oTbl=document.getElementById("mytable")
   if count>2 then
   oTbl.deleteRow()

   count = count -1

   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 = "G:\ExecutionAlpha\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&nbsp&nbsp&nbsp&nbsp&nbsp</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>
Dont forget to change the export directory or you will get an error.

Thanks for your help.... (I just started with VBScript and this porject is needed tomorrow at 8 AM!! )

obang