I've got a grid of buttons which I create dynamically and I'm trying to register the "onclick" for each one. I need to know the position of the button.
The big problem is that getref does not work if the routine referenced has parameters. As a result, I am dynamically creating a bunch of callbacks, one for each button.
Is there a better way of doing this?
The big problem is that getref does not work if the routine referenced has parameters. As a result, I am dynamically creating a bunch of callbacks, one for each button.
Is there a better way of doing this?
Code:
<HTML>
<HEAD>
<TITLE>Button Grid</TITLE>
<META NAME="GENERATOR" Content="Microsoft Visual Studio">
<META HTTP-EQUIV="Content-Type" content="text/html; charset=UTF-8">
<script language="vbscript">
const XMAX = 9, YMAX = 9
dim grid ()
' Grid callback
sub cbGrid (x, y)
MsgBox cstr(x) & "," & cstr(y)
end sub
sub window_onLoad
dim x, y, button, cbname, cbbody, newline
redim grid(XMAX, YMAX)
for y = 0 to YMAX
for x = 0 to XMAX
cbname = "cbGrid" & cstr(x) & cstr(y)
cbbody = "sub " & cbname & _
": cbGrid " & cstr(x) & "," & cstr(y) & _
": end sub"
ExecuteGlobal cbbody
set button = document.createElement ("input")
with button
.type = "button"
.value = " "
.style.width = "20px"
.onClick = GetRef (cbname)
end with
gridcon.AppendChild button
next
set newline = document.createElement ("br")
gridcon.AppendChild newline
next
end sub
</script>
</HEAD>
<BODY>
<fieldset id="gridcon">
</fieldset>
</BODY>
</HTML>