Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
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
 
Old April 14th, 2005, 02:35 PM
Registered User
 
Join Date: Apr 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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";

        }

    }


 
Old April 14th, 2005, 11:57 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

hi y you had used value="" for 'Y' option and Value="Y" for 'N' option.

 
Old April 15th, 2005, 01:24 PM
Registered User
 
Join Date: Apr 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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


 
Old April 18th, 2005, 08:09 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

Even i am also confused,y it wont work.Lemme check it.

 
Old April 18th, 2005, 08:15 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

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.

 
Old April 18th, 2005, 01:59 PM
Registered User
 
Join Date: Apr 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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";

        }

    }

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

 
Old April 18th, 2005, 11:27 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

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"/>






Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing Multiple Checkbox Values arimakidd Classic ASP Professional 5 October 19th, 2007 10:28 AM
Passing a Variable LarryS Beginning PHP 1 August 8th, 2006 07:52 AM
Passing a variable using a checkbox awieland XSLT 1 April 21st, 2005 04:43 AM
Passing variable to a public variable Hudson40 Access VBA 2 February 25th, 2005 06:23 AM
Passing a variable trekmp ADO.NET 1 March 4th, 2004 01:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.