View Full Version : bold, italics, underline tagging
robsgaming
01-31-2003, 01:53 PM
Similar to this forum, I want to make something where a user a user clicks B, I, or a U button. A dialog box will come up asking what text to be bold, italicized, or underlined acorrding to what button the press. after they type what they want, they click ok then [ B ]their text[ /B ] will appear in a <textarea> box.
Does anyone have any ideas on how to do this? Thanks in advance for any help.
kdjoergensen
01-31-2003, 04:17 PM
<html>
<head>
<title>format text</title>
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
// constants
var start=0;
var end=1;
var theBox = document.formName.elementName;
// identifiers .. you can add to this list as you like
// if adding indentifiers then include a letter identifier
// and the format start/end (e.g. B and [ b] and [ /b])
var type["I"] = ["[ I]","[ /I]"];
var type["B"] = ["[ B]","[ /B]"];
var type["U"] = ["[ U]","[ /U]"];
function paintTxt(identifer,txt){
return type[identifier][start] +txt+ type[identifer][end];
}
function getTxtFromUser(){
return prompt("Enter text to format ","your text here");
}
function coordinate(indenKey){
var txt = getTxtFromUser();
var formTxt = paintTxt(indenKey,txt);
theBox.value = theBox.value + formTxt;
theBox.focus();
return false;
}
//-->
</SCRIPT>
</head>
<body>
<table border=2 cellspacing=5 cellpadding=5>
<tr><td>
<A HREF="javascript: coordinate('I')">Italics</a>
</td>
<td>
<A HREF="javascript: coordinate('B')">Bold</a>
</td>
<td>
<A HREF="javascript: coordinate('U')">Underline</a>
</td>
</tr>
</table>
<form name="formName">
<textarea name="elementName" rows=20 cols=30>
</textarea>
</form>
</body>
</html>
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.