кодове в такст

Post Reply
User avatar
skatebord
Потребител
Потребител
Posts: 725
Joined: Sun Dec 09, 2007 3:11 pm
Answers: 51
Location: Karlovo, Bulgaria

Post by skatebord » Fri Feb 29, 2008 1:02 pm


Pr0oF
Турист
Турист
Posts: 565
Joined: Sat Jun 10, 2006 8:48 pm
Answers: 38

Post by Pr0oF » Sat Mar 01, 2008 7:13 pm

Code: Select all

function addCode(obj, tag) {
	var t = document.forms['forma'].elements['nowina'];
	var c = '';

	if(obj.opened == true) {
		c = '[/' + tag + ']';
		obj.opened = false;
		obj.value = tag;
	}
	else {
		c = '[' + tag + ']';
		obj.opened = true;
		obj.value = tag + '*';
	}

	t.value += c;
}
Съответно, <form> ще има параметри name="forma" и <textarea> ще бъде с name="nowina".
На линковете добавяш съответно
onclick="addCode(this, 'b');" - bold
onclick="addCode(this, 'i');" - italic
onclick="addCode(this, 'u');" - underline

Post Reply