Passing a variable using a checkbox
I am using the following code to pass a 'Y' or 'N' variable to our database based on a users checking or unchecking the checkbox. The code works if the database is storing a 'N' and the use checks the box and set the value to 'Y'. When the user submits the page it updates the database to a 'Y'. But when the user reopens the page and now the checkbox is checked becasue the value in the database is now a 'Y' and the user unchecks the checkbox and submits the request the applcation crashes and the database does not update to an 'N' it remains a 'Y'.
Another words the functionality works fine going from 'N' (unchecked) to 'Y' (checked), but not the other way from 'Y' (checked) to 'N' (unchecked).
Thank you in Advanced
<xsl:choose>
<xsl:when test="contains(MarriedFileSingle, 'Y')">
<INPUT type="checkbox" name="MarriedFileSingle" value="" checked="yes" onclick="javascript:marriedSingle()"/>If married, but withholding at single rate, select Single status and check here.
</xsl:when>
<xsl:otherwise>
<INPUT type="checkbox" name="MarriedFileSingle" value="Y" onclick="javascript:marriedSingle()" />If married, but withholding at single rate, select Single status and check here.
</xsl:otherwise>
</xsl:choose>
function marriedSingle(){
if (document.W4Form.MarriedFileSingle.checked==true){
document.W4Form.MarriedFileSingle.value = "Y";
}
else (document.W4Form.MarriedFileSingle.checked==false) {
document.W4Form.MarriedFileSingle.value = "N";
}
}
|