Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Decent JS spellchecker?

Status
Not open for further replies.

youradds

Programmer
Jun 27, 2001
817
GB
Hi,

I'm looking for a decent JS/PHP (or even .cgi) spell checker that I can impliment on a textarea.

I already have one, but when I use it on a text-area - it seems to "remove" that text-area from the list of form fields (not quite sure of the mechanics of it). Its a shame as ait was a VERY cool AJAX one.

Without it - this works fine:

Code:
  if (document.edit.post_message.createTextRange && document.edit.post_message.cursorPosition) {
    var cursorPosition = document.edit.post_message.cursorPosition;
    cursorPosition.text = cursorPosition.text.charAt(cursorPosition.text.length - 1) == ' ' ? '[' + tag + '] ' : "[" + tag + "]";
  }
  else {
    document.edit.post_message.value += "[" + tag + "]";
  }
  document.edit.post_message.focus();
  return;

..but as soon as you add this into the TEXTAREA:

Code:
accesskey="/test2/spell_checker.php"

..it screws up, and gives fatal errors:

Error: document.edit.post_message is undefined
Source File: Line: 77

TIA

Andy
 
Hi,

Thanks for th reply. This is the script ;


I'm accessing the script itself with:

Code:
<link rel="stylesheet" type="text/css" href="/test2/css/spell_checker.css">
<script src="/test2/cpaint/cpaint2.inc.compressed.js" type="text/javascript"></script>
<script src="/test2/js/spell_checker.js" type="text/javascript"></script>

(the rest seems to be done via the JS file, where it reads the textarea's, and converts them to be workable as a "spellchecker")

The code that doesn't wanna work, is:

Code:
<script language="Javascript">
function addTag(tag) {

/*
   alert($('post_message').val());
*/


  if (document.edit.post_message.createTextRange && document.edit.post_message.cursorPosition) {
    var cursorPosition = document.edit.post_message.cursorPosition;
    cursorPosition.text = cursorPosition.text.charAt(cursorPosition.text.length - 1) == ' ' ? '[' + tag + '] ' : "[" + tag + "]";
  }
  else {
    document.edit.post_message.value += "[" + tag + "]";
  }
  document.edit.post_message.focus();
  return;
}

function checkText(text) {
  if (text.createTextRange)
   text.cursorPosition = document.selection.createRange().duplicate();
  return true;
}


</script>

...and the textarea looks like:

<textarea title="spellcheck_icons" accesskey="/test2/spell_checker.php" name="post_message" id="spell" style="width: 400px; height: 150px;" />

I've got the "WebDeveloper" for FF, and when I via Forms > View Form Information, the post_message field dissapears (until I remove accesskey="/test2/spell_checker.php", but that obviously stops the spellchecker from working :()

Cheers

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top