This is a function that I've used in my web pages for years. It stopped working a few years ago and I never bothered to look at why. Today I finally took the time to debug it and I get a message that says String.concat is not a function. I've done some looking but it's been a long time since I've done any coding of any kind and truthfully I'm lost. I'm looking at PHP manuals and documentation but have not found what I need (yet).
Thanks, Rich K.
// ---------------------------------------------------------------------------
// Make selected text bold, italicized or underlined by adding the appropriate
// HTML tags around the selected text.
// ---------------------------------------------------------------------------
function makeText($char)
{
var $tb = document.getElementById("textinput");
if (document.selection)
{
var str=document.selection.createRange().text;
if (str != '' && str!= 'undefined')
{
var sel=document.selection.createRange();
sel.text="<"+$char+">"+str+"</"+$char+">";
}
}
else if (typeof $tb.selectionStart != 'undefined')
{
var $before, $after, $selection;
if ($tb.selectionStart == 0) // Starts at left edge?
$before = ''; // No before then
else
$before= $tb.value.substring(0, $tb.selectionStart);
$selection = $tb.value.substring($tb.selectionStart, $tb.selectionEnd);
if ($selection != "")
{
if ($tb.selectionEnd == $tb.value.length) // Ends at left edge?
$after = ''; // No after then
else
$after = $tb.value.substring($tb.selectionEnd, $tb.value.length);
$tb.value= String.concat($before, "<"+$char+">", $selection, "</"+$ch+">", $after);
}
}
$tb.focus();
return false;
}
Thanks, Rich K.
// ---------------------------------------------------------------------------
// Make selected text bold, italicized or underlined by adding the appropriate
// HTML tags around the selected text.
// ---------------------------------------------------------------------------
function makeText($char)
{
var $tb = document.getElementById("textinput");
if (document.selection)
{
var str=document.selection.createRange().text;
if (str != '' && str!= 'undefined')
{
var sel=document.selection.createRange();
sel.text="<"+$char+">"+str+"</"+$char+">";
}
}
else if (typeof $tb.selectionStart != 'undefined')
{
var $before, $after, $selection;
if ($tb.selectionStart == 0) // Starts at left edge?
$before = ''; // No before then
else
$before= $tb.value.substring(0, $tb.selectionStart);
$selection = $tb.value.substring($tb.selectionStart, $tb.selectionEnd);
if ($selection != "")
{
if ($tb.selectionEnd == $tb.value.length) // Ends at left edge?
$after = ''; // No after then
else
$after = $tb.value.substring($tb.selectionEnd, $tb.value.length);
$tb.value= String.concat($before, "<"+$char+">", $selection, "</"+$ch+">", $after);
}
}
$tb.focus();
return false;
}