Web Analytics Made Easy -
StatCounter getting checkbox to pass value when unchecked - CodingForum

Announcement

Collapse
No announcement yet.

getting checkbox to pass value when unchecked

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

  • getting checkbox to pass value when unchecked

    I really don't think this can be done but...

    I have a list of checkboxs, and when I submit the form
    only those boxs that are "checked" will be returned
    to my .cgi script with the value set.

    Is there anyway to to have an alternate value returned.


    ....wait.... idea just hit just have to test it.

    I'm thinking prior to submitting, I scan the elements for
    the checkboxes I want. If they are unchecked, then check
    them, but then change their value, so my .cgi can check
    for the changed value.

    so... my HTML would read

    <INPUT TYPE="CHECKBOX" NAME="BOXX" VALUE="YES">

    my javascript will set the .checked to true, then
    set the .value to "NO"

    otherwise the value will be "YES"


    Or is there an HTML way to set an unchecked value?

    THanks
    George

  • #2
    Your idea will work unless the user happens to have JavaScript disabled. Why not just change the server side code to handle the non-presense of unchecked items?
    Check out the Forum Search. It's the short path to getting great results from this forum.

    Comment


    • #3
      I can't. Since some of the other functions of the page
      will determine which check boxes are on the form to
      start with. They are dynamically created, so I never
      know which check boxs were there prior to the page
      creation.

      George

      Comment


      • #4
        in this case, javascript won't be disabled. It's a LAN thing,
        and if javascript is disabled, nothing will work.
        Just as only IE is used, which makes coding a bit easier as well
        (not because it's IE, but I don't need to do x-browser checking)

        Comment


        • #5
          If you add some additional "hidden" form fields to clue the next page in as to what should be present you can still avoid developing the javascript.
          Check out the Forum Search. It's the short path to getting great results from this forum.

          Comment


          • #6
            yea...I could....but there could a hundred or so checkboxes,
            so the hidden field's value could grow to to quite a length.
            I'm already passing a lot of data back and forth, I'd rather
            not add to it. Since the majority of the boxes will be checked
            I'd rather not add a thousand bytes to check if one box
            is unchecked.

            George

            Comment

            Working...
            X