Jump to content

Bold Italic etc..


manix

Recommended Posts

Hey.. I've been struggling with this for a while now and I still can't figure it out..

 

What I want to do is, have a nice little edit panel under the comment section which the user can use while writing a comment, kinda something like the one in all the forums and sites, having the bold butotn italic button underlined button and others, but a little bit different:

 

When the user clicks a button once in his textarea the tag is being opened and the button remains clicked and when the user clicks it again the tag is being closed and the button's image is changed back to normal, but I completely failed in my attempts to do that simple looking function and I'm really getting pissed already. I'd show you my code if you like but I really prefer not to because it's unbelievably embarrassing ;s

 

Thanks in advance..

Link to comment
https://forums.phpfreaks.com/topic/240190-bold-italic-etc/
Share on other sites

It can be done with Javascript. You could alternate a value that the button reads and changes each time it is pressed. If the value is 0 then it can insert [ b ] into the text area (and then change the value to 1), and if it's 1 then it can insert [ /b ] into the text area (and then change the value back to 0 again).

 

8)

Link to comment
https://forums.phpfreaks.com/topic/240190-bold-italic-etc/#findComment-1233757
Share on other sites

yes that's my idea too but I failed to do it in PHP, and since I'm not rly familiar with javascript at all I posted here if you could give me a solution, if not I guess I'm going to have to familiarize with java :D

 

here's my failz0red code anyway

 

<form name="izrot">
<textarea name="pole"></textarea>
<?php $imgname="Bold1.jpg";$inputstring[1]="<b>";$inputstring[2]="</b>";$bold=2;
echo "<img src='buttons/Bold1.jpg' name='bold' onmouseover='if($bold=1){$bold=2;}else{$bold=1;}' onclick='izrot.pole.value=izrot.pole.value + $inputstring[$bold]'/>";
?>
</form>

 

And yes, I know the image isn't being changed but if I manage to succeed in making it insert the tag, the image wont be a problem.

Link to comment
https://forums.phpfreaks.com/topic/240190-bold-italic-etc/#findComment-1233759
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.