<?php
for ($x = 8; $x < 0; $x--) {
<input type="radio" name="day"
<?php if (isset($day) && $day=="monday") echo "checked";?>
value="mon">Monday 08:30 AM - 10:30 AM <br>;
}
?>
我希望单选按钮工作八次然后被禁用
答案 0 :(得分:1)
<?php
header("Content-type: text/html; charset=utf-8");
session_start();
// store count result in SESSION
if (isset($_SESSION['count_days']) && !empty($_SESSION['count_days'])) {
// if there is already quantity of days
$count_days = $_SESSION['count_days'];
} else {
// or there are no days yet
$count_days = 0;
}
// after data posted look if radio was checked
if (isset($_POST['day'])) {
$day = $_POST['day'];
} else {
$day = 0;
}
$count_days += $day;
// save quanitity in SESSION
$_SESSION['count_days'] = $count_days;
if ($count_days == 8) {
$checkbox_status = ' disabled';
} else {
$checkbox_status = '';
}
// echo $count_days;
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form action="" method="post">
Checkbox1 <input type="radio" name="day" value="1"<?php echo $checkbox_status; ?>>
<input type="submit" value="Send">
</form>
</body>
</html>