我是PHP和Javascript的新手,剛開始有兩種形式的網站,一種形式有5個複選框,另一種形式有5個單選按鈕。當您更改單選按鈕的單選按鈕時,它會刷新頁面並使用新值。與複選框相同。不幸的是,如果您更改其中一個表單,然後更改其他表單,則第一個表單值將不再存在。double form refresh
下面的代碼:
<form name='form2' method='post'>
<input type="radio" name="group1" value="all" onClick="if (this.checked) this.form.submit();" <?php if ($_REQUEST['group1'] == null || $_REQUEST['group1'] == "all"){ echo "checked='checked'";}?>/> All<br>
<input type="radio" name="group1" value="Example" onClick="if (this.checked) this.form.submit();" <?php if ($_REQUEST['group1'] == "Example"){ echo "checked='checked'";}?>/> Example<br>
<input type="radio" name="group1" value="clifton" onClick="if (this.checked) this.form.submit();" <?php if ($_REQUEST['group1'] == "clifton"){ echo "checked='checked'";}?>/> Clifton<br/>
<input type="radio" name="group1" value="fruita" onClick="if (this.checked) this.form.submit();" <?php if ($_REQUEST['group1'] == "fruita"){ echo "checked='checked'";}?>/> Fruita<br/>
<input type="radio" name="group1" value="loma" onClick="if (this.checked) this.form.submit();" <?php if ($_REQUEST['group1'] == "loma"){ echo "checked='checked'";}?>/> Loma<br/>
</form>
<form name='form3' method='post'>
<input type="checkbox" name="option1" value="smoking" onClick="if (this.checked) this.form.submit();" <?php if(isset($_REQUEST['option1'])){ echo "checked='checked'";} ?>/> No Smoking<br>
<input type="checkbox" name="option2" value="kids" onClick="if (this.checked) this.form.submit();" <?php if(isset($_REQUEST['option2'])){ echo "checked='checked'";} ?>/>Good for Kids<br>
<input type="checkbox" name="option3" value="wheelchair" onClick="if (this.checked) this.form.submit();" <?php if(isset($_REQUEST['option3'])){ echo "checked='checked'";} ?>/>Wheelchair Accessible<br>
<input type="checkbox" name="option4" value="alcohol" onClick="if (this.checked) this.form.submit();" <?php if(isset($_REQUEST['option4'])){ echo "checked='checked'";} ?>/>Serves Alcohol<br>
<input type="checkbox" name="option5" value="delivery" onClick="if (this.checked) this.form.submit();" <?php if(isset($_REQUEST['option5'])){ echo "checked='checked'";} ?>/>Delivery Servicee<br>
</form>
我試圖讓這兩種形式輸入要保存的其他形式的變化也是如此。 任何幫助將高度讚賞。謝謝!
你已經描述了一個問題,但問題在哪裏? – bos 2012-07-20 00:53:20
不能爲他們說話,但我認爲OP希望兩套輸入都能保持其價值。 – machineghost 2012-07-20 00:54:18
哎呀對不起@machineghost是正確的...我會更新 – infinity 2012-07-20 00:55:07