doutao1282
2014-11-25 13:41
浏览 329
已采纳

HTML表单:在输入中显示文本(textarea)

I have a form that I pre-fill with my database data. It is working perfectly for all my input. I have a text (that I enter in my database using a textarea). But when I am using the following the text does show in the text area (if I change it to input it is working but I do not have several lines and column allowed with textarea)

<textarea 
    rows="4"
    class="form-control" 
    name="roster_description" 
    id="roster_description" 
    placeholder =
        <?php if ($description_roster){
                echo '"'.$description_roster.'"'; 
            } else {
                echo "";
            }?>>
</textarea>

any ideas?

图片转代码服务由CSDN问答提供 功能建议

我有一个表格,我预填充了我的数据库数据。 它完全适用于我的所有输入。 我有一个文本(我使用textarea输入我的数据库)。 但是,当我使用以下内容时,文本显示在文本区域中(如果我将其更改为输入它正在工作,但我没有几行和列允许使用textarea)

 <  code>&lt; textarea 
 rows =“4”
 class =“form-control”
 name =“roster_description”
 id =“roster_description”
 placeholder = 
&lt;?php if($ description_roster)  {
 echo'“'。$ description_roster。'”';  
}其他{
 echo“”; 
}?&gt;&gt; 
&lt; / textarea&gt; 
   
 
 

任何想法?

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • dongtingxiao4697 2014-11-25 13:52
    已采纳

    Just tested it and it works:

    <textarea 
        rows="4"
        class="form-control" 
        name="roster_description" 
        id="roster_description" 
        placeholder = "<?php if ($description_roster) echo $description_roster;?>">
    </textarea>
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • dsoy71058 2014-11-25 14:07

    Ok no clue why but the following is working:

    <textarea class="form-control" id="description_roster" 
              name="description_roster" rows="4"
              placeholder=<?php
                             if ($description_roster){
                                 echo '"'.$description_roster.'"';
                             } else {
                                 echo "";
                             }
                           ?>
    ></textarea>
    

    Thanks to those who had a look

    评论
    解决 无用
    打赏 举报
  • dongxing4643 2014-11-25 16:55

    The issue was that your statement:

    echo "";
    

    doesn't produce quotation marks - it produces the empty string. What you want is to replace this with:

    echo '""';
    

    which will produce placeholder=""> instead of placeholder=>.

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题