Better ways to get a checkbox value? - InfoPath Dev
in

InfoPath Dev

Better ways to get a checkbox value?

Last post 06-20-2008 04:13 PM by Greg Collins. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 06-18-2008 12:36 PM

    • marcdeb
    • Not Ranked
      Male
    • Joined on 05-16-2008
    • Groningen, the Netherlands
    • Posts 5

    Better ways to get a checkbox value?

    (Using Infopath 2003/Jscript): Up till today I always use selectSingleNode("...").text to get the value of a control. With a checkbox, that will return "true" or "false", depending on if it is checked or not. However, I never liked string-comparing to "true" or "false", specifically because one can configure the outcome of the checkbox to be "TRUE/FALSE" or "1/0". That compair will fail and will have to be adjusted accordingly.

    It seems better to compare to the boolean constants 'true' and 'false'. Is that possible, without a cast? I tried to use selectSingleNode("...").nodeTypedValue but that also seems to return a string.

    Tnx!

    Filed under:
  • 06-20-2008 04:13 PM In reply to

    Re: Better ways to get a checkbox value?

    You will need to either cast it or write a small conversion function which returns a true boolean value. The problem is that if you are not in control of the form, then you could be getting anything back from a check box.... red/blue, yes/no, up/down, 1/0, light/dark, whatever!

    If you are specifically in control of the form, and your not going to mess up existing data, then I suggest that you always set your check boxes to use the values you prefer. Writing a conversion function could be useful because you can keep adding pairs to compare in there.

Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.