 |
| XML General XML discussions. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

April 14th, 2005, 02:35 PM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Passing 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 because the value in the database is now a 'Y' and the user unchecks the checkbox and submits the request the applica:)tion 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";
}
}
|
|

April 14th, 2005, 11:57 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hi y you had used value="" for 'Y' option and Value="Y" for 'N' option.
|
|

April 15th, 2005, 01:24 PM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
This was the one that worked by sending a Y to the Database:
option 'Y' value=""
option 'N' value="Y"
All the other senirios did not work?
i.e.
option 'Y' value="Y"
option 'N' value=""
option 'Y' value="Y"
option 'N' value="N"
option 'Y' value="N"
option 'N' value=""
option 'Y' value=""
option 'N' value=""
I am really fustrated, I have tryed everything. Please continue to see what I can do? Santhi, thank you for your help.
Thanks,
Allan
|
|

April 18th, 2005, 08:09 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Even i am also confused,y it wont work.Lemme check it.
|
|

April 18th, 2005, 08:15 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Allan,one suggestion why dont you create one hidden field for setting "Y" or "N".When the checkbox is checked,set the values as "Y" else "N".I hope this will avoid your confusion.
|
|

April 18th, 2005, 01:59 PM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I tryed to hide the first checkbox <INPUT type="hidden" and when the page refreshed after the checkbox was selected the checkbox was hidden and the user is not able to uncheck the box?
************************************************** **********
xsl:choose>
<xsl:when test="contains(MarriedFileSingle, 'Y')">
<INPUT type="hidden" 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";
}
}
************************************************** **********
|
|

April 18th, 2005, 11:27 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi see the code below.This is how i asked u to change..
<xsl:choose>
<xsl:when test="contains(MarriedFileSingle, 'Y')">
<INPUT type="checkbox" name="MarriedFileSingle" 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" 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.HidValue.value = "Y";
}
else (document.W4Form.MarriedFileSingle.checked==false) {
document.W4Form.HidValue.value = "N";
}
}
<input type="hidden" name="HidValue"/>
|
|
 |