Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a Checkbox to pass a variable in XSLT

Status
Not open for further replies.

awieland

Programmer
Apr 18, 2005
36
US
I have a single checkbox that will pass a 'Y' when it is checked and a 'N' when unchecked.
I can get the 'Y' to pass when the box is checked, but when the box is unchecked I can NOT get the variable 'N' to pass, it passes nothing only a blank variable causing the application to crash.

************************************************************

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:eek:therwise>
<INPUT type="checkbox" name="MarriedFileSingle" value="Y" onclick="javascript:marriedSingle()" />If married, but withholding at single rate, select Single status and check here.
</xsl:eek:therwise>
</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";

}

}

************************************************************
 
you are not setting 'N'
try this:


function marriedSingle(){
document.W4Form.MarriedFileSingle.value =
(document.W4Form.MarriedFileSingle.checked==true)?'Y':'N';
}
 
simonchristieis,

I will try your suggestion and let you know what happens. How do you know I am not setting 'N'?

Thanks
 
simonchristieis,

I tryed your suggestion and it still would not let me uncheck the box and send an 'N' to the database, the application crashed. Although, I was able to check the box and send a 'Y' to the database. I know I am close to solving this error, so please let me know what I should try next?

Thanks, awieland

Here is the code:

<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:eek:therwise>
<INPUT type="checkbox" name="MarriedFileSingle" value="Y" onclick="javascript:marriedSingle()" />If married, but withholding at single rate, select Single status and check here.
</xsl:eek:therwise>
</xsl:choose>

*****************************************

function marriedSingle(){
document.W4Form.MarriedFileSingle.value =
(document.W4Form.MarriedFileSingle.checked==true)?'Y':'N';
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top