Someone - **please, please, please** help :-( .js problem

Someone - **please, please, please** help :-( .js problem

Post by milkywa » Mon, 17 Jan 2005 22:01:36


ello,

I have an HTML page that I am trying to import 2 .js file (I created)
into. These files are: row_functions.js and data_check_functions.js.
Whenever I bring the contents of the files into this HTML file, all is
OK but whenever the functions are separated (as it is now), when I run
the page, I get the following error:

Line 73, object expected.

Line 73 below is:

<INPUT onClick="if (FTry2(PrepObj('FrmX'))) {
addRowToTable('FDependents', form.FDependSocialSecurityNumber.value,
form.FDependLastName.value,
form.FDependFirstName.value, form.FDependMiddleInitial.value,
form.FDependDateOfBirth.value, form.FDependState.value,
form.FDependZipCode.value, form.FDependPhoneNumber.value,
form.FDependAmountPaid.value, form.FDependRelationship.value); } "
type=button value=" Add " name="Add">

In other words, there seems to be something wrong with the "onClick"
event. It does not seem to recognize the functions I have in the other
.js files. It does not get into the "FTry2" or the "PrepObj" functions
(I had placed an "alert" there at the entry point of the functions and
they never fired.

Someone please help :-( What am I doing wrong?





----------------------- HTML PAGE LISTED BELOW ------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv=Content-Type content="text/html;
charset=windows-1252">
</HEAD>
<script language="javascript" TYPE="application/x-javascript"
src="file:///C|Documents and Settings\Desktop\BASE
PAGE\row_functions.js" >
<script language="javascript" TYPE="application/x-javascript"
src="file:///C|Documents and Settings\Desktop\BASE
PAGE\data_check_functions.js" >

<SCRIPT language=JavaScript type="text/javascript">
function PrepObj(Frm) {
alert("got in this shit");
// So written to allow display by ShowFF()
with (document.forms[Frm]) return { Fawm:Frm, A:[
// {F:"Field" W:"What" H:"How" ?R:RegExp ?V:ValFn ?P{Params}},
{F:"FDependSocialSecurityNumber", W:"Social Security Number", H:"be
in ###-##-#### format ", V:RegCheckSocialOK},
{F:"FDependLastName", W:"Last Name", H:"non-blank", V:FmlyOK},
{F:"FDependFirstName", W:"First Name", H:"non-blank", V:FmlyOK},
{F:"FDependMiddleInitial", W:"Middle Initial", H:"non-blank",
V:FmlyOK},
{F:"FDependDateOfBirth", W:"Date of Birth", H:"in valid format
MM-DD-YYYY", V:RegCheckDateOK, V:DateOK},
{F:"FDependState", W:"State", H:"non-blank", V:FmlyOK},
{F:"FDependZipCode", W:"Zip Code", H:" ", V:RegCheckZipOK},
{F:"FDependPhoneNumber", W:"Phone Number", H:" in XXX-XXX-XXXX form
", V:RegCheckUSPhoneOK},
{F:"FDependAmountPaid", W:"Amount Paid", H:"in dollars and cents ",
V:RegCheckUSDollarsOK},
{F:"FDependRelationship", W:"Relationship", H:"non-blank",
V:FmlyOK}
] } }

function loadData(){
addRowToTable(1,2,3,4,5,6,7,8,9,10);
}
</SCRIPT>


<BODY>
<FORM name=FrmX >
<div ID="errmesg"> </div>
Social Security Number <br>
        <INPUT TYPE ="text"
style="width:300px" maxLength=11 name=FDependSocialSecurityNumber>
<br>Last Name<br>
        <INPUT TYPE ="text"
style="width:300px" maxLength=35 name=FDependLastName>
<br>First Name<br>
        <INPUT TYPE ="text"
style="width:300px" maxLength=35 name=
 
 
 

Someone - **please, please, please** help :-( .js problem

Post by Fred O » Mon, 17 Jan 2005 22:52:36


where is 'addRowToTable' defined?

Reduce your problem to the smallest amount of code to still show it
(say one form input and minimal HTML) and re-post - at least get rid of
all the   - use padding or margin or some other layout technique.

Try changing references such as:

form.FDependSocialSecurityNumber.value

to:

forms.FrmX.FDependSocialSecurityNumber.value

Also, all your attribute values should be quoted, not just some of
them. And ditch "language='javascript' " - it's depreciated and
replaced by type="text/javascript".

--
Fred

 
 
 

Someone - **please, please, please** help :-( .js problem

Post by Jeff Nort » Mon, 17 Jan 2005 23:03:44

On 16 Jan 2005 05:01:36 -0800, in comp.lang.javascript "milkyway"



Your script files are pointing to your hard drive. You should make the
links point to the folder within your website. For example the script
files are in a folder called scripts, your <script> tags would look
like:
<script language="javascript" TYPE="application/x-javascript"
src="folder/row_functions.js" >
<script language="javascript" TYPE="application/x-javascript"
src="folder/data_check_functions.js" >

Script tags etc should normally be placed between the <head></head>
tags, the browser could be ignoring them in your code.

The Type attribute should be type="text/javascript" but don't quote me
on that.

---------------------------------------------------------------
XXXX@XXXXX.COM : Remove your pants to reply
---------------------------------------------------------------
 
 
 

Someone - **please, please, please** help :-( .js problem

Post by Richard Co » Tue, 18 Jan 2005 01:03:56

red Oz wrote:
<snip>

The first (left most) item in these property accessors is (in ECMAScript
production rule terms) an Identifier and will be resolved against the
scope chain of the (internally generated, for code defined in an
intrinsic event attribute strings) event handling function (as per ECMA
272 (3rd edition) Section 10.1.4 "Scope Chain and Identifier
Resolution").

As a result, error-free resolution of either of those property accessors
requires that the left most Identifier correspond with a named property
of one of the objects on the function's scope chain that holds a
reference to an object. When closures are not being employed, the normal
scope chain of an executing javascript function will contain the
Activation/Variable object (holding references to the function's formal
parameters, named inner function declarations and local variables) of
the individual execution context followed by the global/window object.
The global/window object would not normally be expected to have
properties named "form" or "forms" and so both of those property
accessors will fail.

In practice some browsers (including the more common ones) add a custom
scope chain to the event handling functions that they internally
generate from intrinsic event attribute string defined code. Those
custom scope chains do include a number of objects from the DOM,
depending on the browser in question. If the browser has added the INPUT
element on which the attribute is specified to the scope chain, then
"form" will resolve as a reference to the W3C HTML DOM specified (and
seemingly universally supported) - form - property of the INPUT element
(or, more precisely the HTMLInputElement interface). And when the -
document - element is added to the scope chain "forms" will be resolved
as the W3C HTML DOM specified - forms - collection of the HTMLDocument
interface (universally implemented in HTML DOMs, but missing form some
older XHTML DOM implementations).

Experimentation has suggested that all of the browsers that do provide a
custom scope chain for event handling functions internally generated
from intrinsic event attribute strings will place the element on which
the attribute appears on that scope chain. However, the placing of a
reference to the - document - on that scope chain is less commonly
implemented. Thus the proposed switch from the original property
accessor to the proposed alternative will sacrifice some cross-browser
compatibility for no particularly good reason.

On the other hand, the creating of custom scope chains for internally
generated event handling functions is not defined in (or even suggested
by) any published specification/recommendation, so it is surprising that
where they are created they differ in behaviour. And it is also not
surprising that some (otherwise reasonably standards compliant) browsers
do not implement such a mechanism at all (leaving their internally
generated event handling functions with scope chains that satisfy ECMA
262 but go no further). For these browsers both property accessor
formulations will error, rather than resolving to useful values.

To maximise the cross-browser compatibility the code defined in the
string values of intrinsic event attributes that code should be written
as if it was the function body definition of any top level
ECMAScirpt/javascript function assigned to an event handling property of
a DOM element. No reliance on the inconstant