In reply to PM:
PHP Code:
var t = document.getElementById('txtFirstValue');
function insertValue(e) {
if (t.value == '') {
t.value = e.value;
e.disabled = "true";
} else {
t.value += ' ' + e.value;
}
}
function validateValue(obj,max) {
var box = obj.name.substr(0,obj.name.lastIndexOf('_')+1);
var cnt=0,i=1;
while(obj.form[box+i]) {
cnt += obj.form[box+i].checked;
i++;
}
if (cnt > max) {
obj.checked = false;
alert('Only choose ' + max + ' Numbers.\n\nTo pick this number, deselect one of the others.');}
}
t.addEventListener('click', insertValue(arg1), 'false');
t.addEventListener('click', insertValue(arg1, arg2), 'false');
Obviously, you'll have to change the arg1 and arg2 to your own passable values and I've taken the liberty to streamline and clean your code a bit. Be careful how you name things... Text1 means nothing to anyone who doesn't have the code in front of them and can cause even your own code to become unmanageable in larger applications. Use single quotes for strings, so that you can save the double quotes for literal quotes within the string. One last thing, the Grammar Nazi in me had to change "unselect" to "deselect".
Bookmarks