retrieving checkbox value as Y and N when it is checked or unchecked
843840Apr 3 2009 — edited Apr 5 2009I have a checkbox and on checking the checkbox , value 'Y' should go to the database. On unchecking the checkbox, value 'N' should go to the database.
Initially , when the db value is Y, it displays the checkbox as checked. but when I uncheck it, the value of the heckbox becomed Null instead of 'N'
Below is the checkbox definition and the javascruipt it calls on onclick event.
<input name="checkname" type="checkbox" <c:if test= "${sData.flag == 'Y' }"> CHECKED </c:if> value="Y" onclick = "check(this)" ></center>
function check(checkbox)
{
var yOrN = (this.checked)?"Y":"N";
checkbox.value =yOrN
if (yOrN == "Y")
checkbox.checked = true;
if (yOrN == "N")
checkbox.checked = false;
}
This is bit urgent to me.. . Please help..