Forum Moderators: open

Message Too Old, No Replies

this.form

...a little help please

         

WhosAWhata

3:05 am on May 12, 2004 (gmt 0)

10+ Year Member



i have the following code

[quote]<html>
<head>
[b]<script src="../spellChecker.js"></script>
<script>
function openSpellChecker( txt ) {
var speller = new spellChecker( txt );
speller.openChecker();
}

</script>[/b]
<style type="text/css">
<!--
.text { background-color:#000066; color:#CCFFFF; border-style:dotted; border-color:#0000FF; }
.button { background-color:#000066; color:#CCFFFF; width:110; }
-->
</style></head>

<body>

<div align="center">
<form action="" method="post" name="form" id="form">
<table width="85%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td width="73%"><h1>New Article</h1>
<h3>Title:
<input name="title" type="text" class="text" id="title" size="100" maxlength="100">
</h3>
<p align="center">By:<?=$penname?> </p></td>
<td width="27%">&nbsp;</td>
</tr>
<tr>
<td><h3>Article:</h3>
<p align="left">
<textarea name="article" cols="110" rows="25" class="text" id="article"></textarea>
</p>
<p align="right">
<input name="Submit" type="submit" class="button" value="Preview">
<input name="Submit" type="submit" class="button" value="Submit">
</p></td>
<td align="center" valign="middle"><p><a href="#" onClick="window.open('stylecodes.php','style')">Style Codes</a></p>
<p><a href="#" onClick="window.open('insertpicture.php','pic')">Insert Picture</a></p>

[b]<p><a href="#" onClick="openSpellChecker(this.form.article)">Spell Check </a></p></td>[/b]

</tr>
</table>
<p>&nbsp;</p>
</form>
<p>&nbsp;</p>
</div>
</body>
</html>[/quote]

when i click the spell check button it returns an error that says

this.form.article is null or not an object
and doesn't open the spell check window

HELP

Elijah

3:26 am on May 12, 2004 (gmt 0)

10+ Year Member



Try replacing this.form.article with document.getElementById('article')

Bernard Marx

8:52 am on May 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



...but give the TEXTAREA an
id="article"
first.

dcrombie

9:14 am on May 12, 2004 (gmt 0)



Your problem is that the link isn't a child of the FORM so it doesn't have a "this.form". If you replace the link with a <INPUT type="button" ...> then you can use "this.form.article" and your code should work.

You could also use: document.forms["form"].article or "document.form.article" as well as the options other people have mentioned above.

WhosAWhata

9:17 pm on May 12, 2004 (gmt 0)

10+ Year Member



ok that makes sense, the original code that i found the spell check on was a button
thanks