Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Marcus 41 posts 61 karma points
    Jan 29, 2011 @ 20:36
    Marcus
    0

    value of checkbox

    right now its just on/off. i would like to set own value. is this possible?

  • Sascha Wolter 615 posts 1101 karma points
    Jan 30, 2011 @ 06:59
    Sascha Wolter
    1

    On/off are already interpretations for the checkbox having an attribute 'checked' or not. I found this article quite helpful:

    http://jquery-howto.blogspot.com/2008/12/how-to-check-if-checkbox-is-checked.html

    You can of course always create your own attributes, say whenever someone modifies the state of your checkbox control you'll set that value to whatever you like, e.g.

    $('input#myCheckbox').attr('checked'){

      $('input#myCheckbox').attr('myOwnValue', 'This is checked now!');

    } else {

      $('input#myCheckbox').attr('myOwnValue', 'Nothing checked here!');

     

    }

    [code written out of top of my head, will most likely not work as is]

    Of course this would invalidate your html, but you can probably live with that if you so want (and need).

    Cheers,

    Sascha

  • Marcus 41 posts 61 karma points
    Jan 31, 2011 @ 17:10
    Marcus
    0

    thank you, although my programmingskills are at "rookie" level.

     

    Regards / Marcus

Please Sign in or register to post replies

Write your reply to:

Draft