當通過$ _POST提交表單時,輸入文件值將保留。就像這樣:textarea和選擇輸入的數據或值保留
if($_POST){
$error = false;
if(!$post['price']){
$error = true;
$error_note['price'] = "*Should not be empty";
}
if($error == false){
//submit/save the data
}
}
<form name="post" id="post" method="post" action="">
<input name="price" value="<?=$_POST['price']?>" class="text-input" type="text" maxlength="15">
<select name="price-type" class="text-input">
<option value="" selected>Select price type</option>
<option value="item">Item</option>
<option value="kilo">Kilo</option>
<option value="rate">Rate</option>
</select>
<textarea class="description" name="description" cols="55%" rows="6"></textarea>
<button class="button" type="submit" name="submit-btn" >SUBMIT</button>
</form>
但我有textarea的和我的表格上選擇輸入。
如何在選擇輸入中保留textarea和選定項目的內容? value="<?=$_POST['price']?>"
不會把這種工作..
做出價值=「isset($ _ POST [ '價格'])? $ _POST ['price']:''「 –
–
檢查textarea的第二條評論。 –