...

View Full Version : Checkbox / Unchecked Value



tomyknoker
02-25-2008, 01:25 AM
I am wondering can you make a checkbox have an un-checked value of 'No' without doing it through php etc

_Aerospace_Eng_
02-25-2008, 04:57 AM
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.

tomyknoker
02-25-2008, 08:43 AM
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:


if ($check1 == "") {
$check1 = "No";
}

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

_Aerospace_Eng_
02-25-2008, 10:59 PM
They only get posted if they are checked so doing something like this would be fine.

for($i = 1; $i <= 45; $i++)
{
if(isset($_POST['check'.$i]))
{
// do something
}
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum