w head:
Kod
<script language=\"javascript\">
var ilei=0;
function wstaw(litera) {
if(litera == 'i'){
if(ilei==0){
document.getElementById('text').value += "[ " + litera + " ]";
ilei++;
}else{
document.getElementById('text').value += "[ /" + litera + " ]";
ilei--;
}
}
}
</script>
var ilei=0;
function wstaw(litera) {
if(litera == 'i'){
if(ilei==0){
document.getElementById('text').value += "[ " + litera + " ]";
ilei++;
}else{
document.getElementById('text').value += "[ /" + litera + " ]";
ilei--;
}
}
}
</script>
w body:
Kod
<form id="formularz" action="dodaj.php" method="post">
<a href="javascript:void(0)" onclick="wstaw('i');">i</a>
<textarea id="text" rows="10" name="odpowiedz" cols="163">$odpowiedz<textarea>
</form>
<a href="javascript:void(0)" onclick="wstaw('i');">i</a>
<textarea id="text" rows="10" name="odpowiedz" cols="163">$odpowiedz<textarea>
</form>
Gdy klikam w " i " to w polu tekstowym za teksem pojawia się " [ i ] " lub "[ /i ]".
Ale ja chciałbym, żeby pojawiało się w miejscu gdzie jest kursor.
Jak to zrobić?