₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,081 members, 8,420,205 topics. Date: Thursday, 04 June 2026 at 01:31 PM

Toggle theme

Code On Button To Echo Tag, Help! - Webmasters - Nairaland

Nairaland ForumScience/TechnologyWebmastersCode On Button To Echo Tag, Help! (808 Views)

1 Reply (Go Down)

Code On Button To Echo Tag, Help! by Joit(op): 3:40pm On Oct 31, 2008
Nairalanders, does anyone know the code to insert/echo tags in a textarea by just clicking specific buttons. E.g To echo <b></b> in a text area if I click Bold button.
Re: Code On Button To Echo Tag, Help! by DualCore1: 9:42pm On Oct 31, 2008
i can't really say what u want but here is what i just coded up, hope this works for u.
Save the whole of this in a html file (e.g mytags.html) and run it


<HTML>
<HEAD>
<script language="JavaScript" type="text/javascript">
//created by Sawyerr Ken www.pctalknigeria.com
// Helpline messages, dis r the messages tht wld show in ya textbox

b_help = "Bold text: text (alt+b)";
i_help = "Italic text: text (alt+i)";
u_help = "Underline text: <u>text</u>";
w_help = "Insert URL: http://url or URL text (alt+w)";

// Shows the help messages in the helpline window, shay u grab this part
function helpline(help) {

document.post.helpbox.value = eval(help + "_help"wink;

}
</script>

</HEAD>
<BODY>
<center>
<form action="" method="post" name="post" id="post">
<table border=0>
<tr>
<td height="20"><input type="button" class="button" accesskey="b" name="addbbcode0" value=" B " style="font-weight:bold; width: 30px" onClick="helpline('b')">
<INPUT class=button onClick="helpline('w')" style="WIDTH: 40px; TEXT-DECORATION: underline" accessKey=w type=button value=URL name=addbbcode16>
<input class=button onClick="helpline('i')" style="WIDTH: 30px; FONT-STYLE: italic" accesskey=i type=button value=" i " name=addbbcode2>
<INPUT class=button onClick="helpline('u')" style="WIDTH: 30px; TEXT-DECORATION: underline" accessKey=u type=button value=" u " name=addbbcode4></td>
</tr>
<tr>
<td height="20">
<INPUT
name=helpbox
value="Click on each button, script by Dual Core aka SawyerrKen for nland" size="80"></td>

</tr>
</table>
</form>
</center>
</BODY>
</HTML>
Re: Code On Button To Echo Tag, Help! by DualCore1: 9:51pm On Oct 31, 2008
oops, double post, sorry. lol
Re: Code On Button To Echo Tag, Help! by Joit(op): 10:15am On Nov 03, 2008
Hello Dual Core,

Thank you for the reply.

I am glad to tell you that the code works out well but each button message replaces the previous message. Can't there be a way by which each click will add to the previous button click message instead of replacing it, outright. E.g If I click Bold button in nairaland compose area, instead of it to replace the former text it will (code)add to it.

I need something like the nairaland compose area button function.

I expect your reply. Thanks
Re: Code On Button To Echo Tag, Help! by DualCore1: 10:58am On Nov 03, 2008
i'll be on in it in about half an hour, got a bug to kill.
1 Reply

Please Help, How Do I Place Adsense Code On WordpressAdd Facebook Like/share Button To Your Blog/websiteHow To Add Social Media Sharing Button To Blogger Blog234

HACKING 101Java, Php Or What?How Do I Create A Mailing List Form Into My Site