1
나는 약간의 테스트 html/php 양식을 만들고 있었다. 모든 것은 여기 괜찮습니다 ...하지만 라디오 버튼이 이상하게 작동합니다. 여기에 코드 아래의 이상한 행동의 스크린 샷이 될 것입니다 :HTML 또는 PHP 라디오 버튼이 이상하게 작동합니까?
이html로
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>Differend sided dice</h1>
<form action="dice.php" method="post">
<input type="radio" value="4" name="4side" checked />4 side<br />
<input type="radio" value="10"name="10side" />10 side<br />
<input type="radio" value="20"name="20side" />20 side<br />
<input type="submit" >
</form>
</body>
</html>
PHP의
<html><head></head>
<body>
<?
function rollOut($dice) {
$out = <<<HERE
<p>You rolled <span style="color:red"> $dice </span> of the diec</p>
HERE;
return $out;
}
function diceSide() {
$dicetype = rand(1, 10); /* default */
if (isset($_POST["4side"])) {
$dicetype = rand(1, $_POST["4side"]);
print rollOut($dicetype);
}
else if (isset($_POST["10side"])) {
$dicetype = rand(1, $_POST["10side"]);
print rollOut($dicetype);
}
else if (isset($_POST["20side"])) {
$dicetype = rand(1, $_POST["20side"]);
print rollOut($dicetype);
}
else {
$dicetype = rand(1, 20);
rollOut($dicetype);
}
}
/* init main */
diceSide();
?>
</body>
</html>
그리고 이상한 것은이 스크린 샷에 부착 I`ll :
모든 버튼은 체크 박스와 같은 역할을합니까 ??? 어떤 정보?
즉, 제출 유형이 코드를 중단한다는 의미입니까? 나는
코드 샘플 – Bogdan
으로 업데이트 할 것입니다. 그렇지 않으면 php 파일은 정상적으로 작동합니다 ...하지만 필요한 것은 생성하지만 ... 처음부터 isset에 대한 내 오류 검사입니다. 나는 체크 박스를 사용했지만 ... 그건 실수 였어. –