Plik edytor.js:
Cytat
var b = 2;
function tag(v, tagadd, newbut, tagclose, oldbut, name) {
if (eval(v)%2 == 0) {
eval("window.document.editform."+name+".value = newbut;");
var post = window.document.editform.value;
window.document.editform.value = post + tagadd;
window.document.editform.focus();
} else {
eval("window.document.editform."+name+".value = oldbut;");
var post = window.document.editform.value;
window.document.editform.value = post + tagclose;
window.document.editform.focus();
}
eval(v+"++;");
}
Strona z formularzem:
Cytat
<script src="edytor.js"></script>
</head>
Formularz:
Cytat
<form action="cos" method="cos" name="[color="red"]editform[/color]', 'bold', 'bold');" /></p>
<p>Tytul: <input type="text" name="title" size="50" /><br />
Autor: <input type="text" name="author" size="35" /><br />
Post:<br />
<textarea rows="5" cols="75" name="[color="green"]post[/color]"></textarea></p>
<input type="submit" name="submit" value=Wyslij></form>
Dalej powinienes juz wiedziec co robic
Miejsca oznaczone kolorami mozesz zmienic, aby dostosowac skrypt do swojego formularza.