...

View Full Version : Change checkbox value



ooiyh
08-31-2006, 10:58 AM
Is this how you change checkbox value?
If so, it seems that I cant pass my value for SQL processing once I unchecked the checked box.

Javascipt:


function changevalue()
{
box = eval("document.form1.gopublic");
if (box.checked == false)
{
alert("disallow");
document.form1.gopublic[0].value = "disallow";
}
else
{
alert("allow");
document.form1.gopublic[0].value = "allow";
}
}


HTML


<input name="gopublic" type="checkbox" id="gopublic" value="allow" checked="checked" onclick="changevalue()"/>

Kor
08-31-2006, 12:02 PM
un unchecked checkbox is not an active element, thus it's value will not be submit. Use rather a pair of radio buttons, one of them checeked by default.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum