Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
Това за BBCode ли ти трябва по добре ползвай уроците. След малко ще ти кажа как ще стане това което искаш.miro_94 каза:Трябва ми JS код за добавяне на код в текстово поле.Примерно имам този бутони като натисна бутона това да се добавя в текст полето.Надявам се да сте ме разбрали.Код:<input type="button" value="B" onClick="<b>Тук текста</b>">
miro91 каза:Използвай този урок много е хубав.
http://web-tourist.net/login/login/view.php?st=963
Еми що не използваш урока и от ббкода изтрий другите неща и остави само за болд или каквото ти трябва само така няма да стане както ти искаш.miro_94 каза:miro91 каза:Използвай този урок много е хубав.
http://web-tourist.net/login/login/view.php?st=963
Не ми трябва готова форма а само код който да прави това дето бях написал по-горе.
Galli каза:<head>
<script>
function storeCaret (textEl) {
if (textEl.createTextRange)
textEl.caretPos = document.selection.createRange().duplicate();
}
function insertAtCaret (textEl, text) {
if (textEl.createTextRange && textEl.caretPos) {
var caretPos = textEl.caretPos;
caretPos.text =
caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
text + ' ' : text;
}
else
textEl.value = text;
}
</script>
</head>
<body>
<form name="form">
<textarea name="textarea" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);">
</textarea>
<input type="hidden" name="text" value="Това ще се инсъртва">
<input type="button" value="insert" onclick="insertAtCaret(this.form.textarea,this.form.text.value);">
</form>
</body>
<script src="editor.js" type="text/javascript" ></script>
<?
function bbcode($text){
$text=preg_replace("/\[b\](.+?)\[\/b\]/s", '<b>$1</b>',$text);
$text=preg_replace("/\[i\](.+?)\[\/i\]/s", '<i>$1</i>',$text);
$text=preg_replace("/\[u\](.+?)\[\/u\]/s", '<u>$1</u>',$text);
$text=preg_replace("/\[quote\](.+?)\[\/quote\]/s", '<table cellspacing="1" width="100%" border="0"><tr><td>Quote:</td></tr><tr><td width="100%" style="border:solid 1px black">$1</td></tr></table>',$text);
$text=preg_replace("/\[quote\=(.+?)](.+?)\[\/quote\]/s", '<table cellspacing="1" width="100%" border="0"><tr><td>$1 каза:</td></tr><tr><td width="100%" style="border:solid 1px black">$2</td></tr></table>',$text);
$text=preg_replace("/\[url\](.+?)\[\/url\]/s", '<a href="$1">$1</a>',$text);
$text=preg_replace("/\[url\=(.+?)\](.+?)\[\/url\]/s", '<a href="$1">$2</a>',$text);
$text=preg_replace("/\[img\](.+?)\[\/img\]/s", '<img src="$1" alt="User submitted image" title="User submitted image"/>',$text);
$text=preg_replace("/\[color\=(.+?)\](.+?)\[\/color\]/s", '<span style="color:$1">$2</span>',$text);
$text=preg_replace("/\[size\=(.+?)\](.+?)\[\/size\]/s", '<span style="font-size:$1">$2</span>',$text);
$text=preg_replace("/\[code\](.+?)\[\/code\]/s",'<table cellspacing="1" width="100%" border="0"><tr><td>Code:</td></tr><tr><td width="100%" style="border:solid 1px black">$1</td></tr></table>',$text);
$text = nl2br($text);
return $text;
}
$htmlcode = $_POST['post'];
if (!$htmlcode){
?>
<form action="form.php" method="post" name="editform" onsubmit="return checkForm(this)">
<input type="button" class="button" value="bold" name="bold" onclick="javascript:tag('b', '[b]', 'bold*', '[/b]', 'bold', 'bold');" onMouseOver="helpline('bold')" /><br>
<textarea rows="5" cols="10" name="post" class="form_elements_text"></textarea>
<br>
<input type="submit" name="Post" value="Пусни" class="button"/>
<?
} else {
$htmlcode = htmlspecialchars("$htmlcode", ENT_QUOTES);
echo bbcode("$htmlcode");
}
?>
Galli каза:<head>
<script>
function storeCaret (textEl) {
if (textEl.createTextRange)
textEl.caretPos = document.selection.createRange().duplicate();
}
function insertAtCaret (textEl, text) {
if (textEl.createTextRange && textEl.caretPos) {
var caretPos = textEl.caretPos;
caretPos.text =
caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
text + ' ' : text;
}
else
textEl.value = text;
}
</script>
</head>
<body>
<form name="form">
<textarea name="textarea" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);">
</textarea>
<input type="hidden" name="text" value="Това ще се инсъртва">
<input type="button" value="insert" onclick="insertAtCaret(this.form.textarea,this.form.text.value);">
<input type="hidden" name="novo" value="2">
<input type="button" value="insert" onclick="insertAtCaret(this.form.textarea,this.form.novo.value);">
</form>
</body>
<head>
<script type="text/javascript">
var whohasfocus=0;
var str;
function saveCursorPosition(obj){
if (obj.createTextRange){
obj.selection = document.selection.createRange().duplicate();
}
return true;
}
function insertAtCursorPosition(myTextArea, smilie) {
if (whohasfocus!=3) alert('Cursor not in textfield');
if (whohasfocus==3){
str = smilie;
if (myTextArea.createTextRange && myTextArea.selection) {
var objTxtRange = myTextArea.selection;
objTxtRange2=objTxtRange.text;
objTxtRange.text = (objTxtRange.text.charAt(objTxtRange.text.length - 1) == ' ') ? str + ' ' : str;
myTextArea.selection = null;
}
else {
myTextArea.value += str;
}
document.myForm.myTextArea.focus();
return true;
whohasfocus=0;
}
}
</script>
</head>
<body
onload="document.myForm.myTextArea.focus()"
onClick="whohasfocus=0;return saveCursorPosition(document.myForm.myTextArea);"
onMouseOver="return saveCursorPosition(document.myForm.myTextArea);">
<form name="myForm" title="Click here to insert smilie..." onsubmit="return false;">
<center>
<a href="#"
onClick="return insertAtCursorPosition(document.myForm.myTextArea, 'text 1');">Text</a>
<a href="#"
onClick="return insertAtCursorPosition(document.myForm.myTextArea, 'novo');">Novo</a>
<br>
<textarea onDrag
onBlur="javascript:whohasfocus=3"
onFocus="javascript:whohasfocus=0" wrap="on" name="myTextArea" cols="40" rows="4"
onSelect="return saveCursorPosition(this);"
onClick="return saveCursorPosition(this);"
onKeyup="return saveCursorPosition(this);"></textarea>
</form>
</center>
</body>