Checkbox - InfoPath Dev
in

InfoPath Dev

Checkbox

Last post 01-20-2006 06:54 AM by nukkumatti. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 01-19-2006 02:17 AM

    Checkbox

    Hmm,

    i don't know what is wrong. Somehow it just doesn't work.
    I want to set the value of a checkbox form true to false (uncheck the box) in a change view event.
    How can I do that. Actually it shouldn't be that big of a task ?

    Thx

    Listen to Motörhead cos they play Rock'n Roll :)
    Listen to Motörhead cos they play Rock'n Roll :)
  • 01-19-2006 03:59 AM In reply to

    Hi,
    Please follow the steps below

    1. Drag a check box and a button
    2. Create a new view, Copy the check box from the default view and paste it in the new view
    3. In the default view Double-Click on the Button
    4. Add Rule One: click on Add and click on add actions button.
    5. Select “Set field value” in Action dropdown
    6. Select field in field text box and select “false” in Value text box.
    7. Add Rule two: switch views
    8. Click ok and preview the form.

    I hope this helps you
    Thanks



    suresh
    Infopath Dev
    India
  • 01-19-2006 04:22 AM In reply to

    Ok,

    thx. But actually I would like to do it programmatically but somehow I just cannot change the value of my checkbox.

    I tried:

    nodeCheckbox.nodeValue = false;
    nodeCheckbox.text = "false";
    Actually all different constalations but no....

    Listen to Motörhead cos they play Rock'n Roll :)
    Listen to Motörhead cos they play Rock'n Roll :)
  • 01-19-2006 08:24 AM In reply to

    I just ran the following code in the OnClick of a button and the button behaved as if I was actually clicking the checkbox. What language are you using?

    function CTRL2_5::OnClick(eventObj)
    {
    var check = XDocument.DOM.selectSingleNode( "//my:field1" );

    if( check.text == "true" )
    check.text = "false";
    else
    check.text = "true";

    //XDocument.UI.Alert( "\"" + check.text + "\"" )
    }


    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 01-20-2006 01:49 AM In reply to

    Hi Faus,

    Ok to get more concrete.

    I have one View Appliaction Team and one Layout Team view. Just as short info my document is integrated into K2 workflow.
    I have a check box on the App.Team view cbLayout. If this one is checked the process follows the line rule for the Layout Team.
    Also I have an OnSwitchView Event (C# code by the way)
    As you posted I do the following:

    IXMLDOMNode nodeL				=	thisXDocument.DOM.selectSingleNode("my:myFields/my:cbLayout");

    if(thisXDocument.View.ToString() == "Layout Team View")
    {
    if(nodeL.text == "true")
    nodeL.text = "false";
    }

    But when i switch between the views the checkbox stay checked ALL the time.
    Listen to Motörhead cos they play Rock'n Roll :)
  • 01-20-2006 06:40 AM In reply to

    OK, I think I found your problem. I think the node that your checkbox is referencing is a text node. This will mean that the value of your checkbox will be different than the boolean true/false.

    1) Double-click on the checkbox
    2) Notice the "Value when checked" and "Value when cleared" fields
    3) Use these values in your code OR select Boolean from the data type drop-down list

    I made a checkbox tied to a text node and the default values were "yes" and "no". I hope this helps!



    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 01-20-2006 06:54 AM In reply to

    Hi again,

    and thx for all your help. I already tried almost all possibilities setting the values of the check box. I guess not the one you mentioned right now.
    BUT right in that moment I found out that if I use your code you posted before

    if(nodeL.text == "true")
    nodeL.text = "false";

    just like this in the OnSwitchView event without asking
    if(thisXDocument.View.Name == "Layout Team View")
    it works so i guess I am gonna go for that solution. I am just not sure if that is gonna destroy some of my logic but if then I still can come back to your last posting.
    Thx

    Listen to Motörhead cos they play Rock'n Roll :)
    Listen to Motörhead cos they play Rock'n Roll :)
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.