Click to See Complete Forum and Search --> : Custom Check field


DiLDoG
01-11-2003, 02:43 AM
Hi, I'm trying to make a custom check field. Currently its like this.

<script language="javascript">
function toggle(object) {
var newvalue = (object.innerText=='') ? 'true' : 'false';
object.innerText=(object.innerText=='') ? 'V' : '';
eval("document.form."+object.input+".value='"+newvalue+"'");
}
function check(name, value) {
if (value==true) {
document.write("<div input='"+name+"' class='check' onclick='toggle(this);'>V</div>");
document.write("<input name='"+name+"' type='hidden' value='true'>");
}
else {
document.write("<div input='"+name+"' class='check' onclick='toggle(this);'></div>");
document.write("<input name='"+name+"' type='hidden' value='false'>");
}
}
</script>

<form method="post" action="current_game" name="form">
<script language="javascript">check("field1", false);</script>
<script language="javascript">check("filed2", false);</script>
</form>


Uhm doest work 100%
I would like to have the toggle function lill improved.
Like toggle(this.form) or something so I can use he function for multiple forms

DiLDoG
01-11-2003, 02:14 PM
No the problem is. 4 each check box there is a hidden field too. When I call toggle() the value of the hidden field should change too

DiLDoG
01-11-2003, 02:51 PM
theForm.elements[object.input].value = newvalue;
doesnt work