我创建了一个小文本编辑器,但问题是,当我点击post按钮在mysql中发布时,我的所有文本编辑( 等)都消失了,我的意思是html代码!这是我的代码:
<script type="text/javascript">
function formatText(el,tag){
var selectedText=document.selection?document.selection.createRange().text:el.value.substring(el.selectionStart,el.selectionEnd);// IE:Moz
var newText='<'+tag+'>'+selectedText+'</'+tag+'>';
if(document.selection){//IE
document.selection.createRange().text=newText;
}
else{//Moz
el.value=el.value.substring(0,el.selectionStart)+newText+el.value.substring(el.selectionEnd,el.value.length);
}
}
</script>
<?php
//$maxlength = '9';
echo (
'<div class="enterNews">
<img style="float:left; width:1px; vertical-align:middle" src="icons/whiteHack.png">
<img style="float: left; padding:12px; width:20px; vertical-align:middle" src="icons/pencil.png">
<form enctype="multipart/form-data" name="changer" method="post" action="index.php">
<input class="enterNewsText" name="subject" id="subject" placeholder="'.$entersmallnews_lang.'"
type="text" size="65" maxlength="149" onFocus="this.value='.$blank.'" />
<img style="float: right; padding:10px; width:20px; vertical-align:middle" src="icons/pic.png">
<div class="biggerNew">'); ?>
<textarea onkeyup="textAreaAdjust(this)" style="overflow:hidden" class="enterNewsTextBig" name="news" value="Enter big news" id="markItUp" >Enter Big news here...</textarea><br>
<input type="button" value="Bold" onclick="formatText (news,'b');" />
<input type="button" value="Italic" onclick="formatText (news,'i');" />
<input type="button" value="Underline" onclick="formatText (news,'u');" />
<?php
echo('
<input class="video" name="video" id="video" placeholder="Youtube video link"
type="text" size="65" maxlength="149" />');
<div class="postcontainer"><input class="postFontan" type="Submit" name="submit" id="submit" value="'.$post_lang.'" /></div>
</div></div></form>
答案 0 :(得分:0)
您的问题似乎是标签未定义,这意味着它会抛出错误。如果您在Chrome中点击检查元素控制台日志,那么您可能会看到大量错误