我已經切換到我的 HTML 表單,如下所示<div class="form-group"> <span><b>GAME MODE?</b></span> <div class="btn-group" id="status" data-toggle="buttons"> <label class="btn btn-default btn-on"> <input type="radio" value="1" name="gamemode">ON</label> <label class="btn btn-default btn-off active"> <input type="radio" value="0" name="gamemode" checked="checked">OFF</label> </div> </div>在提交表單上,我獲得了所有 $_POST 值,但只是沒有獲得切換開關的值。我想我遺漏了一些東西。我正在嘗試在 PHP 中像下面那樣獲取它$gamemode=$_POST['gamemode'];但它總是空的。我能知道是否有人可以幫助我正確使用撥動開關嗎?
1 回答

暮色呼如
TA貢獻1853條經驗 獲得超9個贊
您的代碼應該有一個 form 標簽,其 method 屬性設置為 post。然后一旦按下提交按鈕形成$_POST數據,您就可以使用檢索該信息$_POST['gamemode']。我使用了下面的代碼并進行了測試并獲得了1提交ON時間和0提交時間OFF。
<div class="form-group">
<span><b>GAME MODE?</b></span> <div class="btn-group" id="status" data-toggle="buttons">
<form method="post">
<label class="btn btn-default btn-on">
<input type="radio" value="1" name="gamemode">ON</label>
<label class="btn btn-default btn-off active">
<input type="radio" value="0" name="gamemode" checked="checked">OFF</label>
<input type="submit" value="submit" name="submit">
</form>
</div>
- 1 回答
- 0 關注
- 115 瀏覽
添加回答
舉報
0/150
提交
取消