|
|
function w/ parameter
I have a function that when uses the form name works correctly. Should I
pass a variable to the function using either BizReset('bizform') or
BizReset(getElementById('bizform') statements I receive the error
"elements.length is either null or an object".
Any Suggestions?
<script = "text/javascript>
function BizReset(curform) {
len = curform.elements.length;
var blank = ""
for(i=0;i<len;i++) {
if (curform.elements[i].type == "text") {
curform.elements[i].value = blank;
curform.elements[i].disabled=false;
}
}
QuoteLayerOn(0);
DisplayButtons(0);
document.curform.BizName.focus();
}
</script>
|
|
0
|
|
|
|
Reply
|
dthomas (7)
|
3/4/2005 10:43:38 AM |
|
danny wrote:
> I have a function that when uses the form name works correctly. Should I
> pass a variable to the function using either BizReset('bizform') or
Please hang in there, there's quite a bit to talk about here...
This method of calling your function is incompatible with the
code you have posted. If you pass the name of the form as a
string (as above), use:
function BizReset(curform) {
var f = document.forms[curform];
// now do things with f
> BizReset(getElementById('bizform') statements I receive the error
If you are going to reference your form this way, you must put an
id on the form 'bizform' and fix the syntax error.
<form id="bizform" ... >
...
... onclick="BizReset(getElementById('bizform'));" ...
...
function BizReset(curform) {
// curform will be a reference to the form
var len = curform.elements.length;
...
> "elements.length is either null or an object".
> Any Suggestions?
>
> <script = "text/javascript>
<script type="text/javascript">
> function BizReset(curform) {
> len = curform.elements.length;
Unless 'len' needs to be global, keep it local:
var len = curform.elements.length;
> var blank = ""
> for(i=0;i<len;i++) {
Same with 'i'
for(var i=0; i<len; i++) {
> if (curform.elements[i].type == "text") {
> curform.elements[i].value = blank;
The variable 'blank' is not needed, you could just write:
curform.elements[i].value = '';
> curform.elements[i].disabled=false;
> }
> }
> QuoteLayerOn(0);
> DisplayButtons(0);
If these are not part of your problem, remove them for the sake
if fixing your error.
> document.curform.BizName.focus();
You should check that the focus method is supported first (e.g.
older versions of Safari don't). And curform is a reference to
the form, so 'document.' will cause an error:
if (curform.BizName.focus) curform.BizName.focus();
> }
> </script>
>
>
Here is a modified version of your form that shows different ways
to do what I think you are trying to do.
<script type="text/javascript">
// Pass a reference to the form
function BizResetA(curform) {
var len = curform.elements.length;
for(var i=0;i<len;i++) {
if (curform.elements[i].type == "text") {
curform.elements[i].value = '';
curform.elements[i].disabled=false;
}
}
if (curform.BizName.focus) curform.BizName.focus();
}
// Pass the name of the form as a string
function BizResetB(curform) {
var f = document.forms[curform];
var len = f.elements.length;
for(var i=0;i<len;i++) {
if (f.elements[i].type == "text") {
f.elements[i].value = '';
f.elements[i].disabled = false;
}
}
if (f.BizName.focus) f.BizName.focus();
}
</script>
<form action="" name="BizForm">
<input type="text" name="BizName" value="something" disabled>
<input type="button" onclick="
BizResetA(this.form);" value="this.form">
<input type="button" onclick="
BizResetB('BizForm');" value="'BizName'">
<input type="reset">
</form>
--
Rob
|
|
0
|
|
|
|
Reply
|
RobG
|
3/4/2005 2:05:36 PM
|
|
danny wrote:
> I have a function that when uses the form name works correctly. Should I
> pass a variable to the function using either BizReset('bizform') or
> BizReset(getElementById('bizform') statements I receive the error
> "elements.length is either null or an object".
> Any Suggestions?
>
BizReset(document.getElementById('bizform'));
or better:
BizReset(document.forms['bizform']);
Mick
> <script = "text/javascript>
> function BizReset(curform) {
> len = curform.elements.length;
> var blank = ""
> for(i=0;i<len;i++) {
> if (curform.elements[i].type == "text") {
> curform.elements[i].value = blank;
> curform.elements[i].disabled=false;
> }
> }
> QuoteLayerOn(0);
> DisplayButtons(0);
> document.curform.BizName.focus();
> }
> </script>
>
>
|
|
0
|
|
|
|
Reply
|
Mick
|
3/4/2005 3:42:19 PM
|
|
Mick / Rob,
Thanks. Excellent explanations. Everything is working correctly.
"danny" <dthomas@planet-inc.net> wrote in message
news:112gf086kk14571@corp.supernews.com...
> I have a function that when uses the form name works correctly. Should I
> pass a variable to the function using either BizReset('bizform') or
> BizReset(getElementById('bizform') statements I receive the error
> "elements.length is either null or an object".
> Any Suggestions?
>
> <script = "text/javascript>
> function BizReset(curform) {
> len = curform.elements.length;
> var blank = ""
> for(i=0;i<len;i++) {
> if (curform.elements[i].type == "text") {
> curform.elements[i].value = blank;
> curform.elements[i].disabled=false;
> }
> }
> QuoteLayerOn(0);
> DisplayButtons(0);
> document.curform.BizName.focus();
> }
> </script>
>
>
|
|
0
|
|
|
|
Reply
|
danny
|
3/4/2005 5:28:18 PM
|
|
|
3 Replies
99 Views
(page loaded in 0.209 seconds)
Similiar Articles: boxplot - how are outliers determined? - comp.soft-sys.matlab ...... that outliers are not included in the whisker of the boxplot function. ... is taken from the help section describing the "whisker" parameter: Maximum whisker length w. Libname Function and Connection Strings - comp.soft-sys.sas ...I THINK init_string would go in the LIBNAME function's forth parameter, OPTIONS. options names one or more options honored by the specified engine, delimited with ... glut and (Visual)C++ - comp.graphics.api.openglThe idea is to globally access "this" rather than implicitly access it via the first parameter of the function. static void Application::MyReshapeFunc (int w, int h ... Problem solving equation with Bessel functions - comp.soft-sys ...... with respect to the second parameter, and that u*a or w*a are to be the first parameter, and ... modified bessel function - comp.soft-sys.matlab Problem solving equation ... transfer function derivative differentiation - comp.soft-sys ...Hi i have this transfer function G(j*omg) and i need to evaluate the sensitivity function S of it with respect to certain parameters theta_i : ... Mexican hat and Gaussian function - comp.dspBut I don't understand how to > relate the resulting pulse's frequency to the parameters of the > Gaussian function. Could someone enlighten me? Jacobians for Gauss-Newton - comp.soft-sys.matlabOn Jun 4, 3:26=A0pm, "W. eWatson" <wolftra ... or you can optionally supply a user written function ... the necessary Jacobian elements to solve for 7 parameters ... problem with neumann boundary conditions for heat equation - comp ...The M-file looks like: %model heat function pdex clear all close all clc global ... A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0% A parameter ... Mean Variance optimization with FMINCON - comp.soft-sys.matlab ...... minimize the function for portfolio variance (saved in Weights.m): function [Weights] = f(w ... helpdesk/help/toolbox/optim/ug/brn4nh7.html To pass the ExpCov parameters ... output from function - comp.soft-sys.matlabI wrote the following matlab code : function [w] = SOR( A, b, x) %UNTITLED ... comp.soft-sys.matlab I'm > looking for a quick way to output the fit parameters for ... Parameter - Wikipedia, the free encyclopediax is a formal parameter. When the function is used as in. 3 is the actual parameter value that is substituted for the formal parameter in the function definition. function w/ parameter - JavaScript / Ajax / DHTMLLatest Questions. Windows Server 2008 Services and user permissions errors: Invalid Printer Spcecified 108 views; Is it possible to assign a command to a variable and ... 7/30/2012 10:23:06 AM
|
|
|
|
|
|
|
|
|