2012-05-19 139 views
0

什麼是easiset方式來自動填充此字段?自動填充此html字段?

<input type="text" name="start_price" value="<?=$item_details['start_price'];?>" size="8"></td> 

我需要保持在$ item_details,因爲它被傳遞給一些其他的代碼,但在某些情況下,我想自動填充這爲0.00,使其更容易對我來說,我將使用0.00列出一些拍賣

我正在編輯正在使用的PHP生成一些代碼模板,所以理想我只想做一些更改模板,而不必深入到代碼本身

+1

「......但在某些情況下......」什麼情況? –

+1

'if(some case){$ autofill ='0.00'; }其他{$ autofill = $ item_details ['start_price']; }'...'value =「<?php echo $ autofill;?>」' – JJJ

+0

@AlexLunix我的意思是我需要保留$ item_Details [start_price]部分;所以最短的方式來自動填充這個字段是最好的, –

回答

1

像這樣的事情聽起來就像可能會解決您的問題:

<?php 
    // Whatever logic determines a "special case" stores a boolean value 
    // into the variable $special_case 
    $input_value = !$special_case ? $item_details['start_price'] : '0.00'; 
?> 
<input type="text" name="start_price" value="<?php echo $input_value; ?>" size="8">