Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT 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, 10:48 AM
Registered User
 
Join Date: Apr 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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";

        }

    }

 
Old April 21st, 2005, 04:43 AM
Authorized User
 
Join Date: Apr 2005
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this
Rewrite the javascript coding as


function ld() {
  var flag;
  if(document.f1.checkbox1.checked==true) {
        flag=true;
  }
  else {
        flag=false;
  }

  alert(flag);
}
if flag is true then user have checked
if flag is false then user has not checked







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 Variable using a Checkbox awieland XML 6 April 18th, 2005 11:27 PM
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.