繁体   English   中英

将HTML文本转换为输入字段

[英]Transform HTML text into input field

考虑用PHP创建的标准网页,该网页将从数据库中获取的一些文本变量传递到HTML文件。

我希望能够使用真正的HTML文件作为接口来修改变量的值(这样一来,人们就可以实际看到变量在页面中的位置)。

我尝试简单地使用诸如“ $variable --> < input value="'.$variable.'"/> ”之类的替代$variable --> < input value="'.$variable.'"/> 这仅在某些情况下有效。 例如,如果变量是<a>标记上的内容或变量包含一些HTML,则它不起作用。

您对我如何完成此工作有任何建议吗? 有没有一种方法可以在我的HTML文件中的任何地方强制<input>标记,以便最终用户可以看到它们?

这是默认的和最简单的方式来编辑变量(网站内容)

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Edit</title>
</head>
<body>

<?php
    $title = "Lorem Ipsum";
    $content = "Lorem Ipsum is simply dummy text of the printing and typesetting industry <strong>Lorem Ipsum</strong> has been the industry's <a href=\"http://justin-bieber.com\">standard dummy</a> text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. 
<pre>function toggle(o) {
    var e = document.getElementById(o);
    e.style.display = (e.style.display != 'none' ? 'none' : '' );
}</pre>";
    $author = "Anonymous";
?>

    <form enctype="multipart/form-data" method="post" action="_URL_">
        <label>Tilte</label><br /><input type="text" name="title" value="<?php echo  stripslashes($title) ?>" /><br />
        <label>Content</label><br /><textarea name="content"><?php echo stripslashes($content) ?></textarea><br />
        <label>Author</label><br /><input type="text" name="author" value="<?php echo  stripslashes($author) ?>" /><br />
        <input type="submit" name="submit" value="submit" />
    </form>

</body>
</html>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM