li************@hotmail.com wrote:
Thanks for the replies. I think I am going to go with the 'or this:'
solution provided above. It seems to work with only minor tweaking
to handle the user checking and unchecking the box.
Thanks again. U guys are tooooo smart!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>untitled</title>
<script type="text/javascript">
function initEnable()
{
function set_enable()
{
this.tbox.disabled = !this.checked;
this.tbox.select();
if (!this.checked)
this.tbox.value = this.tbox.defaultValue;
}
var f = document.forms, flen = f.length, el, els, j;
for (var i = 0; i < flen; ++i)
{
els = document.forms[i].elements;
j = 0;
for (; j < els.length; ++j)
{
el = els[j];
if (/\benable\b/.test(el.className))
{
el.tbox = els[++j];
el.onclick = set_enable;
el.onclick();
}
}
}
}
window.onload = initEnable;
</script>
</head>
<body>
<form style="width:180px;">
<input class="enable" type="checkbox" />:::<input type="text" name="t1"
value=" enter name" />
<input class="enable" type="checkbox" />:::<input type="text" name="t2"
value=" enter address" />
<input class="enable" type="checkbox" />:::<input type="text" name="t3"
value=" enter phone" />
<input class="enable" type="checkbox" />:::<input type="text" name="t4"
value=" enter email" />
<br />
<input type="checkbox" /><input type="text" name="t5" value="test" />
</form>
</body>
</html>