473,397 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

JavaScript error - - please help!

There is a spell checker function which is written in VB Script. The
function works well when tested seperately. But when the function is
called from Java Script, the function shows an Error saying " A run
time error has occured. Do you wish to debug? Line :0 , Object
Expected". I just know that it is a Java Script error.
Any suggestions on how to resolve this problem ? What could be the
possible reasons for this error message?

Here is the spell checker function: The way this function is called
from JavaScript is like this :

<span style="float:right;text-align:right;width:50%"><a
href="javascript:SpellCheck(frmMain.taComment.inne rText)">Spelling
Checker</a></span>

<%
function SpellCheck(strComments)
dim msg
dim objWord, objDocument, NumberofWords, NumberofErrors
Set objWord = CreateObject("Word.Application")
Set objDocument = objWord.Documents.Add
objDocument.Content = strComments

NumberOfWords = objDocument.Words.count
NumberOfErrors = objDocument.SpellingErrors.Count

If NumberOfErrors = 0 Then
Response.Write "No Spelling Errors" & "<br>"
'NO spelling errors...
Else
'loop through each word in the document
i=1
while i < NumberOfWords
if objDocument.Words(i).SpellingErrors.Count > 0 then
msg = "Misspelled: " & objDocument.Words(i).text & vblf &
"<br>"
'Yes, there are errors, see if there are any suggestions
for xSuggestions = 1 to
objDocument.Words(i).GetSpellingSuggestions.count
if xSuggestions = 1 then
msg = msg & vblf & "Suggestions: " &
objDocument.Words(i).GetSpellingSuggestions.Item(1 ).Name
else
msg = msg & vblf & " " &
objDocument.Words(i).GetSpellingSuggestions.Item(x Suggestions).Name
end if
next
Response.Write msg
else
end if
i = i + 1
wend
end If
objDocument.saveas "c:\t.doc"
objDocument.close false
set objDocument = nothing
objWord.quit false
Response.Write "Spell check is finished!"
end function
%>
Jul 23 '05 #1
1 1645
questionr wrote:
There is a spell checker function which is written in VB Script. The
function works well when tested seperately. But when the function is
called from Java Script, the function shows an Error saying " A run
time error has occured. Do you wish to debug? Line :0 , Object
Expected". I just know that it is a Java Script error.
Any suggestions on how to resolve this problem ? What could be the
possible reasons for this error message?

Here is the spell checker function: The way this function is called
from JavaScript is like this :

<span style="float:right;text-align:right;width:50%"><a
href="javascript:SpellCheck(frmMain.taComment.inne rText)">Spelling
Checker</a></span>

<%
function SpellCheck(strComments)
dim msg
dim objWord, objDocument, NumberofWords, NumberofErrors
Set objWord = CreateObject("Word.Application")
Set objDocument = objWord.Documents.Add
objDocument.Content = strComments

NumberOfWords = objDocument.Words.count
NumberOfErrors = objDocument.SpellingErrors.Count

If NumberOfErrors = 0 Then
Response.Write "No Spelling Errors" & "<br>"
'NO spelling errors...
Else
'loop through each word in the document
i=1
while i < NumberOfWords
if objDocument.Words(i).SpellingErrors.Count > 0 then
msg = "Misspelled: " & objDocument.Words(i).text & vblf &
"<br>"
'Yes, there are errors, see if there are any suggestions
for xSuggestions = 1 to
objDocument.Words(i).GetSpellingSuggestions.count
if xSuggestions = 1 then
msg = msg & vblf & "Suggestions: " &
objDocument.Words(i).GetSpellingSuggestions.Item(1 ).Name
else
msg = msg & vblf & " " &
objDocument.Words(i).GetSpellingSuggestions.Item(x Suggestions).Name
end if
next
Response.Write msg
else
end if
i = i + 1
wend
end If
objDocument.saveas "c:\t.doc"
objDocument.close false
set objDocument = nothing
objWord.quit false
Response.Write "Spell check is finished!"
end function
%>


You are trying to call a function defined on the server from client-side
JavaScript. This of course, will not work. When a request for this page
arrives at your server, IIS loads the .asp page, parses and executes
anything between <% and %> and sends the resulting *HTML* (and possibly
client-side JavaScript) to your client.

Once the document is at the client, the only thing client-side
JavaScript has access to is client-side code. As far as the server is
concerned, the client is gone, done, finished. The server-side code has
been parsed, executed and the result returned to the client, that
function is simply not available to client-side JavaScript (although it
would be available to code that might need it while that page is being
executed by IIS).

There are a variety of ways of calling server-side code from the client,
but given the fact that you haven't yet grasped the concept of
server/client separation, it would probably be fairly confusing to bring
them up and how they could be used to implement a client-side
spellchecker.

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: TeknoCat | last post by:
Hey everyone, I may be repeating myself here, but if someone sent a reply then I missed it, and I can't get Outlook Express to download any messages more than 2 days old. Anyway, I'm having a...
1
by: JumpingOffPlace | last post by:
Hi, I'm hoping that the wealth of knowledge here can stop me from spinning my wheels on this syntax error for hours. :) Below is the code, and the error I am recieving.... Code: <!DOCTYPE...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.