-1
我創建了一個小的文本編輯者,但是,問題是,當我點擊後按鈕,在MySQL後,我所有的文字塗黑(等)消失,我的意思是HTML代碼!這裏是我的代碼:使<b></b><i></i><u>在文本框</u>和<br>
<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>
哇......你真的需要縮進你的代碼。這是完全不可讀的。 – h2ooooooo
另一件事:你說問題是當你插入文本到數據庫,但你沒有發佈該插入的代碼... –
你是說全文正在從發佈的值或從輸入字段上消失這一頁? –