Knowledgebase Home Page  >  RapidSpell Web Java
Search the Knowledge Base
How can I reduce the amount of repeated script on my page?
https://keyoti.com/kb/Default.aspx?ToDo=view&questId=211&catId=45

Options

Print this page
Email this to a friend

The JSP tags provide a convenient way to setup the spell checker, however they can be replaced with an external Javascript file.  In this example we take the general case of multiple textboxes, and show how to configure the script to check them all from one button.

Main Page

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "
http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <script src="launcher.js"></script>
        <script>
            var popupPage = "popup.jsp";
            var rsTCIntrs1 = new RSStandardInterface("myForm.sourceTextBox1");
            var rsTCIntrs2 = new RSStandardInterface("myForm.sourceTextBox2");
            var rsTCIntrs3 = new RSStandardInterface("myForm.sourceTextBox3");
            var rapidSpellControls = ["rs1","rs2","rs3"];
        </script>
    </head>
    <body>
        <form name="myForm">
            <input type="text" name="sourceTextBox1" value="testt text1"/>
            <input type="text" name="sourceTextBox2" value="testt text2"/>
            <input type="text" name="sourceTextBox3" value="testt text3"/>


            <input   type="button"  value="Check Spelling"  onClick="rswm_RunSpellCheck(true)"    >

        </form>
    </body>
</html>

The important parts are in bold, specifically (from top to bottom);

-A link to launcher.js (see below)

-The path of the page holding the RapidSpellWeb tag.  Often this is RapidSpellCheckerPopUp.jsp

-'rs1', 'rs2', 'rs3' are arbitrary but the part of the variable name, eg. 'rsTCIntrs1' must match that used in the list 'rapidSpellControls'.  

 

Launcher.js

Please download the attachment (bottom of page) and name it 'launcher.js'.  Then place it in the same folder as the main JSP page.


Related Questions:

Attachments: