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>
而且奇怪的事情我心底重視截圖:
所有按鈕的行爲都像複選框?任何信息?
你是說提交類型破壞代碼?我應該使用
我會更新一個代碼示例 – Bogdan 2012-02-03 16:03:49
,否則PHP文件就好了...生成我需要的但是...我雖然從一開始就是我對isset的錯誤檢查,我試過了!我在複選框上做了,但...猜猜它是錯誤的HTML。 – 2012-02-03 16:05:53