Page 1 of 2

[SOLVED] Spell check in textarea (longshot question)

Posted: Thu Nov 13, 2003 11:07 pm
by Bill H
I have this rather fussy client who wants the user (employees) to be able to use a spellchecker in a textarea of an input form. Yeah, in the browser, which might be anything.

Right. I'm holding my breath.

Posted: Thu Nov 13, 2003 11:24 pm
by Paddy
Most web mail programs can spell check. So I am guessing it can be done. Have no idea how though. :)

Posted: Thu Nov 13, 2003 11:44 pm
by Sevengraff
I'm told ieSpell can do that.
or you can try phpSpell

Posted: Fri Nov 14, 2003 12:40 am
by mrvanjohnson
Dude, only the greatest piece of Open Source code out there.

HTMLArea - http://www.interactivetools.com/products/htmlarea/

This thing is great and what I had been looking for for years. A WYSIWYG editor for form text areas. The new beta version 3.0 I believe has Spell Check thanks to a Perl module tie in. So you need to have Perl aviable. Check it out. Some people had broken doen the product into PHP functions but I can't seem to get it working a the JavaScript version works good. Problem is it isn't very compatiable with other browser besides IE sorry :-(

Also, there is a module for phpBB that add Spell Checking to the text area to create postings. I use it on my board. If I find where I got the module I'll add a link but I think they use the phpSpell that Sevengraff referred to. Maybe you can break down that module to understand how they do it.

Posted: Fri Nov 14, 2003 8:22 am
by Bill H
I am astounded. Thanks a ton.

Posted: Fri Nov 14, 2003 8:48 am
by Bill H
Added question: phpspell seems to be the solution, since some of the employees don't use IE, and I believe a couple even use a Mac.

However, the producer's setup instructions only describe using it with various bulliten boards and the contact page is gone missing from their site. Has anyone used this for a simple form that could share the installation and coding procedure for that process with me?

Also, there is some loose talk of "database" and "mysql" is mentioned in passing. Is a mysql database part of the requirement? If so, how is it created. Most servers (including the one I use) have limits on this sort of activity.

Hmmm. This is looking less like a solution. Information is a bit skimpy.

Posted: Fri Nov 14, 2003 12:38 pm
by mrvanjohnson
I know PHPSpell uses a MySQL DB. Looks like all the installs are for Bulletin Board and CMS modules.

If you don't want to use a Database, what would you want to use for the dictionary, a text file?

Like I mentioned, the HTMLArea uses a Perl Module to talk to an online Dictionary, perhaps you can break down that JavaScript and Perl and figure out something for yourself.

The only other thing I can thing of off the top of my head, if you can’t use any other language but PHP and you don’t have access to a database is to create a dictionary flat file and make some creative Regular Expressions. Then parse your input from a text area against the Dictionary File looking for words that aren’t in the dictionary file (by loading the flat file into an array). If it comes across one, use RegEx to determine a word to recommend. It would be a lot of overhead but it’s a work around.

If you do this, make the code a project that other people can contribute to and see how much better it gets. I’m sure there are a lot of people who would like a spell checker that isn’t dependent on anything but PHP with no database required.

Posted: Fri Nov 14, 2003 2:32 pm
by Bill H
HTMLArea is supported for IE only, so like IEspell that isn't going to provide a solution. My customer's employees use various browsers, including Macs.

The site in question is currently using a mysql database, so if phpspell merely adds a table to that database that's not a problem. If it attempts to create a new database that will be a problem. The producer's documemtation doesn't say.

Kind of hard to believe that this utility can only be used with a bulliten board. I'm hoping soneone can (a) give me pointers on how to use it in a simple form, or (b) tell me how to contact the producer, since there is no contact information on the producer's site.

Posted: Fri Nov 14, 2003 2:53 pm
by Sevengraff
I got phpSpell to work with my blog script. It will make one new table that is 9.2 megs, and will take a while to install.
the file Install Instructions/native_mysql_install.txt will tell you how to install it for a non-forum i believe.

Posted: Fri Nov 14, 2003 5:09 pm
by Bill H
Thanks, Sevengraff, I believe I have the gist of it. One point for clarification (since you have done this successfully yourself).
You will also need to edit the Spellmessage.js file and change where the field links to on all four lines it is referenced.
a) I think I'm seeing it referenced five times actually.
b) that would consist the following change if I am correct:

Code: Select all

LinkToField = document.forms[0].message;
// since the textarea is named "description"
LinkToField = document.forms[0].description;
Am I on the right track?

Posted: Fri Nov 14, 2003 9:08 pm
by Sevengraff
Yeah, your doing it good. It does appear 5 times, but the first time is just declaring the var. You need to change it where it does all those if statements.

Posted: Fri Nov 14, 2003 11:30 pm
by Bill H
Thanks for the input. It will be a couple weeks (hm, actually, mid December) before I implement this, but I will post back and let you know how it works.

Posted: Tue Nov 18, 2003 9:28 am
by Bill H
Hmmmm, not working for me. The installation was no problem, and the database table was created properly. I am not getting a spell check, however. When I click on the button nothing happens and there is an "error on page" message in the status bar of my (IE 5.5) browser.

Here is the relevant code:

Code: Select all

<HEAD>
<TITLE>Foobash Company of San Diego California</TITLE>
<link href="../foobash.css" rel="stylesheet" type="text/css">
</HEAD>
<script language='javascript' src='spelling/spellmessage.js'></script>

<BODY TEXT="#0000b0" BGCOLOR="#ffffff" LINK="#0000b0" VLINK="#0000b0" ALINK="#0000b0">
<center>

<form method='post' action='subreport.php'><table width=720>
<tr><td  class="black-6" width=720 colspan=4>Other observations<br>
<textarea name="narr" rows=3 cols=86></textarea><br>
<input type="button" class="" Value="Spell Check" onclick="openspell();"></td></tr>
Here is the spellmesasage.js code:

Code: Select all

if (ie4) LinkToField = self.post.narr;
          if (gecko) &#123;
            LinkToField = parent.document.post.narr;
            height = height + 6;
          &#125;
          if (op6) &#123;
             LinkToField = document.forms&#1111;0].narr;
             height = height + 10;
             width = width + 10;
          &#125;
          if (op7) LinkToField = document.forms&#1111;0].narr;
          if ((op6 || op7) && typeof(LinkToField) == "undefined") LinkToField = document.forms&#1111;1].narr;
Any ideas what the "error on page" is?

Posted: Tue Nov 18, 2003 9:30 am
by JayBird
If you double click the yellow caution icon that appears, it will tell you more detailed info about the error.

Post what it says then i can help ya.

Mark

Posted: Tue Nov 18, 2003 9:41 am
by Bill H
Thanks for speedy reply. It says:

Error: 'self.post.narr' is null or not an object
Code: 0

Come to think of it, the usual reference I have used in similar circumstances is the one shown esewhere in the script "document.form[0].narr"