我都有兩個文字區域用自己的提交按鈕,像這樣:提交的數據只有在特定的按鈕被點擊
<textarea style="width: 200px; height: 22px; resize: none" type="text" name="housetypeData"></textarea>
<input type="submit" name="newHousetype" value="New house"></input>
<textarea style="width: 200px; height: 22px; resize: none" type="text" name="architectData"></textarea>
<input type="submit" name="newArchitect" value="New architect"></input>
和PHP根據像這樣發佈的數據響應:
if (!empty($_POST['housetypeData'])) {
echo 'new housetype';
}
elseif (!empty($_POST['architectData'])) {
echo 'new architect';
}
問題是不管在哪個字段中鍵入文本,兩個按鈕都會提交數據。我該如何做到這一點,只有名稱爲「newHousetype」的按鈕提交字段「housetypeData」的數據,而其他兩個字段的數據相同?
只是使用2種不同的形式... – ProGM 2014-09-11 10:08:29