View Single Post
  #1 (permalink)  
Old Oct 15th, 2007, 21:03
AdRock's Avatar
AdRock AdRock is offline
SuperMember

SuperMember
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to AdRock
BBC Text Editor With Javascript

This is probably one for Rakuli as he has seen the JavaScript file in question.

I have a BBcode editor but there is no error trapping when checking if the form textarea is empty.

If I try and click one of the buttons for bold, italic etc without entering aything on the form I get the Error on Page in the bottom left corner and it points to line 29 with the message
Quote:
"window.document.editform.content.value is null or not an object"
Here is the function which causes the error
Code: Select all
 
function tag(v, tagadd, newbut, tagclose, oldbut, name)
{
    var r = document.selection.createRange().text;
    rr = tagadd + r + tagclose;
    if(r)
    {
 document.selection.createRange().text = rr;
    }
    else
    {
 if (eval(v)%2 == 0)
     {
     eval("window.document.editform."+name+".value = newbut;");
     var content = window.document.editform.content.value;
     window.document.editform.content.value =  content + tagadd;
     window.document.editform.content.focus();
     }
     else
     {
     eval("window.document.editform."+name+".value = oldbut;");
     var content = window.document.editform.content.value;
     window.document.editform.content.value = content + tagclose;
     window.document.editform.content.focus();
     }
     eval(v+"++;");
    }
}
Reply With Quote