【问题标题】:autofill this html field?自动填充这个 html 字段?
【发布时间】:2012-05-26 14:31:34
【问题描述】:

自动填充此字段的最简单方法是什么?

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

我需要保留 $item_details,因为它会被传递给其他代码,但在某些情况下,我想将其自动填充为 0.00 以方便我,因为我将使用 0.00 列出一些拍卖

我正在编辑一个 php 使用的模板来生成一些代码,所以理想情况下我只想对模板进行一些更改,而不必深入研究代码本身

【问题讨论】:

  • "...但在某些情况下..." 什么情况?
  • if( some case ) { $autofill = '0.00'; } else { $autofill = $item_details[ 'start_price' ]; } ... value="&lt;?php echo $autofill; ?&gt;"
  • @AlexLunix 我的意思是我需要保留它的 $item_Details[start_price] 部分;所以自动填充此字段的最短方法是最好的,
  • @Juhana 这将是一个很好的答案......
  • 换句话说如何自动填充和传递 0.00 作为 start_price

标签: php html autofill


【解决方案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">

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-02
    • 2016-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-10
    • 2016-12-22
    相关资源
    最近更新 更多