Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Posts
    459
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Checkbox / Unchecked Value

    I am wondering can you make a checkbox have an un-checked value of 'No' without doing it through php etc

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Why would you need to do this? If the value isn't posted then it wasn't checked. You can give a default element to it. I don't see the issue checking with php to see if it was checked.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Posts
    459
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Because I have 45 checkbox's and if they aren't selected then they get entered into the database as nothing, but this overrides their default value of 'No'... So it just means I have to have 45 if statements like so:

    PHP Code:
    if ($check1 == "") {
    $check1 "No";
    }

    if (
    $check2 == "") {
    $check2 "No";


  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    They only get posted if they are checked so doing something like this would be fine.
    PHP Code:
    for($i 1$i <= 45$i++)
    {
    if(isset(
    $_POST['check'.$i]))
    {
    // do something
    }

    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •