Announcement

Collapse
No announcement yet.

Boolean input not getting set

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Boolean input not getting set

    I'm having an issue where the true/false value of a checkbox on a form of mine is not getting set no matter if it's checked or unchecked. Is there a special way to set up boolean inputs in Miva?

    <input id="myfield" class="flex-column__checkbox" type="checkbox" name="myfield" value="&mvte:global:myfield;">

    #2
    You need to check if the value is there and then put the "checked" attribute in if it is.

    Code:
    <mvt:if expr="NOT ISNULL g.myfield">
      <input id="myfield" class="flex-column__checkbox" type="checkbox" name="myfield" value="&mvte:global:myfield;" checked>
    <mvt:else>
      <input id="myfield" class="flex-column__checkbox" type="checkbox" name="myfield" value="&mvte:global:myfield;">
    </mvt:if>
    M.A.D.* since 1997

    http://www.scotsscripts.com

    *miva application developers

    Comment


      #3
      No, the problem isn't if it's checked (that it easily confirmed and works as expected for a checkbox), but that it does not modify the g.myfield... so it's always null no matter what the input is.

      Comment


        #4
        The value needs to be something no matter what, so put a 1 in there for the value instead of &mvte:global:myfield; - if the global myfield is null then you'll never get a value for the checkbox.
        M.A.D.* since 1997

        http://www.scotsscripts.com

        *miva application developers

        Comment


          #5
          What's the context of the whole form?
          Bruce Golub
          Phosphor Media - "Your Success is our Business"

          Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
          phosphormedia.com

          Comment

          Working...
          X