我有兩組html03形式的單選按鈕button
和button1
。我使用下面的代碼來表單提交後保持單選按鈕被檢查
1.keep默認值檢查(question1
爲第一組和answer2
爲下集)的形式後
2.保持用戶選擇單選按鈕提交
<div id="button_set1">
<input onClick="show_seq_lunid();" type="radio" name="button" value="Yes" <?php if(isset($_POST['button']) && $_POST['button'] == 'Yes') echo ' checked="checked"';?> checked /><label>question1</label>
<input onClick="show_list_lunid();" type="radio" name="button" value="No" <?php if(isset($_POST['button']) && $_POST['button'] == 'No') echo ' checked="checked"';?> /><label>answer1</label>
</div>
<div id="button_set2">
<input onClick="os_hpux();" type="radio" name="button1" value="Yes" <?php if(isset($_POST['button1']) && $_POST['button1'] == 'Yes') echo ' checked="checked"';?> /><label>question2</label>
<input onClick="os_others();" type="radio" name="button1" value="No" <?php if(isset($_POST['button1']) && $_POST['button1'] == 'No') echo ' checked="checked"';?> checked /><label>answer2</label>
</div>
這裏,如果我使用下面的代碼,第二個單選按鈕button1
不會粘在表單提交後的用戶選擇上,它會變回默認的選中狀態.ie answer2
。但第一組單選按鈕工作正常。 如果我從代碼中刪除默認的checked
選項,那麼這兩個單選按鈕在表單提交後工作正常。我怎樣才能保持表格後檢查的單選按鈕,而提交使用無線電
您需要一些服務器端魔術。你在後端使用PHP嗎? – codefreak
您必須將表單處理返回給您的元素狀態。 –
是的我使用php – acr