I'm trying to setup an HTA with frames. What I want to happen is when an item is checked in the first frame it moves to the second frame. The easy solution would be to use a list box, but the actual data I'll be using will be longer than a single row of a list box.
Anyhow, here's my HTA:
And here's scripts.vbs:
One problem with this code is that the oNext.Focus doesn't seem to work, but I'm not getting an error (unless oNext is nothing). I'd thought it maybe had to do with me focussing before the reload was completed, but I added the readystate line and it doesn't make a difference. Any help here would be appreciated.
Anyhow, here's my HTA:
Code:
<html>
<head>
<HTA:APPLICATION/>
<script type="text/vbscript">
Sub Window_OnLoad
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.CreateTextFile("junk.htm")
oFile.Write "<script src=""scripts.vbs"" type=""text\vbscript""></" & "script>" & vbCrLf
For i = 1 to 10
sID = "chk" & cStr(i)
oFile.Write _
"<input type=checkbox id='" & sID & "' " & _
"name='" & cStr(i) & "' " & _
"onPropertyChange='SubForCheckBoxes me'/>" & _
"<label for='" & sID & "'>" & sID & "</label></br>" & vbCrLf
Next
oFile.Close
oFrame1.location.replace("junk.htm")
Set oFile = oFSO.CreateTextFile("junk2.htm")
oFile.Close
oFrame2.location.replace("junk2.htm")
End Sub
</script>
</head>
<iframe id=oFrame1 application=yes width=100% src="junk.htm"/>
<iframe id=oFrame2 application=yes width=100% src="junk2.htm"/>
</frameset>
</html>
And here's scripts.vbs:
Code:
Const ForReading = 1
Const ForAppending = 8
Sub SubForCheckBoxes(oMe)
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.OpenTextFile("junk2.htm",ForAppending)
oFile.Write "<input type=checkbox id='" & oMe.ID & "' checked=true/>"
oFile.Write "<label for='" & oMe.ID & "'>" & oMe.ID & "</label></br>"
oFile.Close
top.oFrame2.location.reload
Set oFile = oFSO.OpenTextFile("junk.htm",ForReading)
sAll = oFile.ReadAll
oFile.Close
aAll = Split(sAll,vbCrLf)
Set oFile = oFSO.CreateTextFile("junk.htm")
For Each sLine in aAll
If InStr(sLine,oMe.ID) = 0 Then oFile.Write sLine & vbCrLf
Next
sNext = cStr(cInt(oMe.Name) + 1)
top.oFrame1.location.reload
Do While top.oFrame1.document.readystate<>"complete"
Loop
oNext = top.oFrame1.document.getElementsByName(sNext)
If oNext Is Nothing Then
Else
oNext.Focus
End If
End Sub
One problem with this code is that the oNext.Focus doesn't seem to work, but I'm not getting an error (unless oNext is nothing). I'd thought it maybe had to do with me focussing before the reload was completed, but I added the readystate line and it doesn't make a difference. Any help here would be appreciated.