> At present we've only discussed HTML... 
>
Fair enough ...
> Perhaps an option list is not the right thing to be using? Without a
> bit of example code to show what you are trying to achieve, any
> suggestions are just guessing. Even broken code that comes close may
> do, or an example on a site somewhere.
Unfortunately, I still have not setup my web server yet (still playing
with the BSD setup ...), so in case you have a moment to look at this,
I'll post it here.
This does _basically_ what I want. It creates a binary competition tree
and has a user select from this initial pool of competitors all the
winners to a final champion.
The problems are:
1) I don't want the tree to start populated ... I want to force the
user to select all winners.
2) If a user selects a winner to be champion (say, in this test script
team1), then goes back and selects a team to defeat team1 (say team2),
then team2 is propagated up the tree. I would like to clear the user
selections above that change (if it affects the parent node)
and force a re-selection.
Any comments on the script are more than welcome, and with my
apologies:
--------------------------- <snip> ----------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript">
var sgLevels = 4;
function IPow(base, exp) {
var i, ans;
if (exp < 0) {
return 0;
}
ans = 1;
for (i = 0; i < exp; i++) {
ans *= base;
}
return ans;
}
function GetLevel(id) {
var elements = IPow(2, (sgLevels-1));
var i;
for (i = sgLevels-1; i >= 0; i--) {
if (id < elements) {
return i;
}
id -= elements;
elements /= 2;
}
return -1;
}
function GetLevelBase(level) {
var elements = 0;
var i = 0;
for (i = sgLevels-1; i > level; i--) {
elements += IPow(2, i);
}
return elements;
}
function GetChildID(id, childnum) {
var level = GetLevel(id);
var ans;
if (level == -1 || level == sgLevels-1) {
return -1;
}
ans = GetLevelBase(level+1) + 2*(id - GetLevelBase(level)) + childnum;
return ans;
}
function GetParentID(id) {
var level = GetLevel(id);
var ans;
if (level <= 0) {
return -1;
}
ans = GetLevelBase(level-1) + (id - GetLevelBase(level) - (id%2))/2;
return ans;
}
function PosTeam(id, name, left, top) {
var tag = '"team' + id + '"';
var command = '<p style="position:absolute; left:' + left + '; top:' + top + '" ';
command += 'id=' + tag + 'name=' + tag + '>' + name + '</p>';
return command;
}
function PosBox(id, left, top, width) {
var tag = '"box' + id + '"';
var command = '<select style="position:absolute; left:' + left + '; top:' + top + '; width:' + width + '" ';
command += 'id=' + tag + ' name=' + tag + ' onChange="UpdateBox(' + id + ', 1);"><option></option><option></option></select>';
return command;
}
function InitBox(id) {
var level = GetLevel(id);
var tmp;
var cid;
var me;
var i;
if (level == -1 || level == sgLevels-1) {
return;
}
me = document.getElementById('box' + id);
if (level == sgLevels-2) {
for (i = 0; i < 2; i++) {
cid = GetChildID(id, i);
tmp = document.getElementById('team' + cid);
me.options[i].value = tmp.innerHTML;
me.options[i].text = tmp.innerHTML;
}
} else {
for (i = 0; i < 2; i++) {
cid = GetChildID(id, i);
tmp = document.getElementById('box' + cid);
me.options[i].value = tmp.options[tmp.selectedIndex].value;
me.options[i].text = tmp.options[tmp.selectedIndex].value;
}
}
}
function UpdateBox(id, first) {
var level = GetLevel(id);
var tmp;
var cid;
var me;
var i;
var changed;
var val;
if (first == 1) {
UpdateBox(GetParentID(id), 0);
}
if (level == -1 || level > sgLevels-2) {
return;
}
changed = 0;
me = document.getElementById('box' + id);
val = me.options[me.selectedIndex].value;
for (i = 0; i < 2; i++) {
cid = GetChildID(id, i);
tmp = document.getElementById('box' + cid);
me.options[i].value = tmp.options[tmp.selectedIndex].value;
me.options[i].text = tmp.options[tmp.selectedIndex].value;
}
cid = GetChildID(id, me.selectedIndex);
tmp = document.getElementById('box' + cid);
if (val != tmp.options[tmp.selectedIndex].value) {
UpdateBox(GetParentID(id), 0);
}
}
</script>
<title>Tester Tree</title>
</head>
<body>
<form action="">
<input type="button"
name="foo"
value="foo"
onClick="alert('**** You');">
</form>
<form name="myform" action="">
<script type="text/javascript">
var str;
var i, j, ct;
var len = 100;
var wid = 40;
var stop;
var space = 1;
var linetop;
ct = 0;
stop = IPow(2, sgLevels - 1);
for (i = 0; i < sgLevels; i++) {
for (j = 0; j < stop; j++) {
linetop = ((j+1)*space*wid) + 100 - (wid/2)*(space-1);
if (i == 0) {
str = PosTeam(j, 'team' + (j+1), 3, linetop-33);
document.write(str);
} else {
str = PosBox(ct, (i*len)+3, linetop-25, len-

;
document.write(str);
InitBox(ct);
}
ct++;
}
stop /= 2;
space *= 2;
}
</script>
</form>
</body>
</html>
---------------------- <snip> -----------------------------------