Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XML
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 14th, 2005, 02:35 PM
Registered User
 
Join Date: Apr 2005
Location: Palm Beach, Florida, USA.
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";

        }

    }


Reply With Quote
  #2 (permalink)  
Old April 14th, 2005, 11:57 PM
Friend of Wrox
 
Join Date: Oct 2003
Location: Chennai, TamilNadu, India.
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.

Reply With Quote
  #3 (permalink)  
Old April 15th, 2005, 01:24 PM
Registered User
 
Join Date: Apr 2005
Location: Palm Beach, Florida, USA.
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


Reply With Quote
  #4 (permalink)  
Old April 18th, 2005, 08:09 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Chennai, TamilNadu, India.
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.

Reply With Quote
  #5 (permalink)  
Old April 18th, 2005, 08:15 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Chennai, TamilNadu, India.
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.

Reply With Quote
  #6 (permalink)  
Old April 18th, 2005, 01:59 PM
Registered User
 
Join Date: Apr 2005
Location: Palm Beach, Florida, USA.
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";

        }

    }

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

Reply With Quote
  #7 (permalink)  
Old April 18th, 2005, 11:27 PM
Friend of Wrox
 
Join Date: Oct 2003
Location: Chennai, TamilNadu, India.
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"/>

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:22 AM.


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