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
dthomas (7)
3/4/2005 10:43:38 AM
comp.lang.javascript 38066 articles. 17 followers. javascript4 (1315) is leader. Post Follow

3 Replies
251 Views

Similar Articles

[PageSpeed] 46
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
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
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
danny
3/4/2005 5:28:18 PM
Reply:
Similar Artilces:

Regarding system function
Hi All, Please have a look the below program #include<stdlib.h> int i = system("pwd"); I compiled the above program in UNIX ,it got compiled and executed with out any errors.It prints the present working directory.Am having certain doubts about this program. 1) without main how it got executed 2)is the system funcion is static 3) is the shell had executed that system command if i write simply #include<stdlib.h> system("pwd") it's thwoing errors at ...

using C library functions in C++
Hi, I am learning C++ and already have a good experience in C. We have some of the application in C which we want to move it to C++. Will there be any issue in using a C library function in C++. regards, Rajkumar.G On Sep 21, 11:51 am, mthread <rjk...@gmail.com> wrote: > Hi, > I am learning C++ and already have a good experience in C. We have > some of the application in C which we want to move it to C++. Will > there be any issue in using a C library function in C++. > > regards, > Rajkumar.G Appendix C.2 of the C++ standard discusses this issue in deta...

The right function
Hi, Don't know the right function to use here. I have a php file containing text only that will contain references to smilies formatted such as "... then I told him the punch line (wink) ..." - obviously I want to detect the (xxx) smilie and replace with an image. I can sort of do this using multiple lines of code like this ... $mytext= str_replace("(wink)", "<IMG SRC=\"wink.gif\">", $mytext); $mytext= str_replace("(smile)", "<IMG SRC=\"smile.gif\">", $mytext); $mytext= str_replace("(laugh)", &q...

global in Embedded MATLAB Function
I am adopting some MATLAB codes into some Embedded MATLAB Function blocks in my Simulink model. These codes contain 'global' functions which are not supported by Embedded MATLAB Function. How can I circumvent this problem? ...

regarding system function
Dear All, In Php If I send a command to system function then It will return 1 on success and 0 on failure. So based upon that value I can to further work. But In Python If I send a command to system function then It will return 0 only for both conditions(success and failure). So What I need to do for this. I want the result like php system function. regards Prabahar ________________________________________________________________________ Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony praba kar <prabapython@yahoo.co.i...

MATLAB function usage #2
Can anyone tell me if MATLAB automatically uses "pointer-type methods" behind the scenes to transfer data between the main program and function calls? I have a function that would be called hundreds of thousands of times from inside an iterative loop. Also, I have a huge data matrix which need be used inside this function and I am wondering if using that data matrix as an input to a function would significantly reduce the computational efficiency. If yes, then are there any clever ways for handling such issues? Thanks Look at nested functions. I think loren's blog answers yo...

Stem function
All How could we plot two sets of data with different colours using stem function on the same figure.? Please help !! thnks Jack "Jack Dean" <w106pjs@yahoo.com> wrote in message news:eee5b99.-1@webx.raydaftYaTP... > All > > How could we plot two sets of data with different colours using stem > function on the same figure.? > Please help !! > > thnks > Jack Put your data into two columns of the same array. If your data are not of the same length it's a little more complicated, but not much. >>stem(randn(10,2),randn(10,2)) OP: <SNIP wa...

periodic function in matlab function block
in my simulink project,I have to write a equation by "Matlab Function" block. my periodic equation (with Ts period) is as following: A = 5 ; 0 < t < Dmin*Ts A = exp(-(t - Dmin*Ts)/Ts) ; Dmin*Ts < t < Ts A(t+Ts) = A(t) %================================= i wrote following code in Matlab function block % code : function A = fcn(t) Ts = 2; Dmin = 0.25; m = floor(t/Ts); t1 = t - m*Ts; if t1>=0 && t1<=Dmin*Ts A = 5; elseif t1 > Dmin*Ts && t1 < Ts A = exp(-(t1-Dmin...

Have question regarding parameter usage in verilog
Hi all, I am new to systemverilog and I have to write synthesizable .sv. I have some peculiar requirement and I have thought of following pseudo code for my requirement. My requirement: parametrized number of registers and bit widths in each registers. Following shows an example reg1 [0:13] reg2 [0:3] .. .. .. .. .. .. reg100 [0-34] ================================================== code ================================================== module top (); parameter no_of_regs = 100; paramerer register1_width = 13; paramerer register2_width = 3; paramerer register3_wi...

directly using the non-default output argument from a function
Hi, Is there a way to make direct use of a non-default output argument from a function? In other words, suppose I have a function [out1,out2,out3] = func (x,y,z), is there a way to manipulate the call to func so that it just returns 'out3'? For instance, instead of >> [~,ind] = sort(x) >> do_something_with_indices( ind ) I'd like to do something like >> do_something_with_indices( some_clever_function( sort(x) ) ) Is there any 'subsref'-type magic that can be used here? I realize that the two-step procedure is clearer, but for my ...

Problems with Favorite function.
Every days I save a Favorite directory by the specific button but after the restart of the system Pro/eng 2000i2 forgets the path. Could someone to help me please? Thanks in advance for your support. It needs to be saved in your config.pro "UTE" <roberto.olivieri@cmsspa.it> wrote in message news:2pnuocFn7ph8U1@uni-berlin.de... > Every days I save a Favorite directory by the specific button but > after the restart of the system Pro/eng 2000i2 forgets the path. > > Could someone to help me please? > > Thanks in advance for your suppo...

US-MA-Natick: Systems Administrator, SME w/MS SMS, Win NT, Win 2K; 6M (45292957611)
US-MA-Natick: Systems Administrator, SME w/MS SMS, Win NT, Win 2K; 6M (45292957611) =================================================================================== Position: Systems Administrator Reference: SMC01301 Location: Natick MA Duration: 6M Skills: Candidate must be an SME with MS SMS including: enterprise SMS architecture; inventory and reporting; package development and deployment. Knowledge of other enterprise management tools providing similar functionality is a plus. Leade...

Reset state of transfer function
Hi, Does anyone know how I can reset the state of a transfer function block in Simulink (i.e., reset back to the initial conditions)? I tried using an "Enabled Subsystem" and placing the Transfer Fcn block there but it seems that the state is not reset when Enable changes ... Thanks! On 9/2/2014 8:14 PM, Peter Mairhofer wrote: > Hi, > > Does anyone know how I can reset the state of a transfer function block > in Simulink (i.e., reset back to the initial conditions)? > > I tried using an "Enabled Subsystem" and placing the Transfer Fcn bl...

Boost function and bind issue
This code compiles: boost::asio::ip::tcp::acceptor m_acceptor; // declared in a class connector::pointer new_conn(new connector(m_acceptor.io_service())); m_acceptor.async_accept ( new_conn->socket(), boost::bind ( &timingserver::handle_accept, this, boost::asio::placeholders::error, new_conn ) ); So now I want to pull out the boost::bind part and make a function object of it. boost::function < void ( const boost::system::error_code &, boost:...

Return Value of Function ?!?!
Hello, I have a problem with my function here. The Function read out a Description from a Norton Ghost Image File. This works mostly with this Function. The Problem is when i try to return the value "Chars" out of my function at the end of the Function like: .... FUNCTION = Chars END FUNCTION then i get an Error: Relational operator expected Line 230: FUNCTION = Chars when i try it like this: FUNCTION = LEN(Char) the function returns a numeric value. The Return Value of this function should be the Variable "Chars". Any Idea what went wr...

Calling functions from functions from functions ...
Lets say I have a function g(p,x) where x and p are of some defined type. I also have a function NewtonR which I can use like so: x = NewtonR(g,p,x0) There is also another function I want to call ImplicitTrap which can be done as: u = ImplicitTrap(g,p,u0,step,n) This function defines a function of g, and it is this function that I'd like to pass to NewtonR. Can it be done? Basically the code is implementing the implicit trapezoidal rule for numerical integration with the NR solver being used at each step with automatic differentiation being used to handle the differentiation. M...

SAS Parameter Excution From oracle data base in sas EG
Hi,can any one plz help me out how to execute text parameter from sas EG via SAS Stored process here im posting my program, can any one tel me where im doing mistake %GLOBAL LOAN_V; %GLOBAL ASOFDATE; %let LOAN_V=ALYL5; %LET ASOFDATE=31OCT2010; data _null_; LENGTH DATE $ 10.; DATE2 ="&ASOFDATE"D; DATE3=COMPRESS(PUT(DATE2,YYMMDD10.)); DATE=COMPRESS(DATE3,'-'); call symput ("DATE1",DATE); run; %put =&DATE1; data _null_; length DATE $ 10.; LOAN_V2 ="&LOAN_V"; LOAN_V=PUT(LOAN_V2,10.); call symput("LOAN_V6",LOAN_V); run; %put =&am...

Random Functionality
I want to create a script that has random functionality. I want the script to randomly choose between an unknown number of subroutines and run one of them. By "unknown" I mean that the neither names of the subroutines, the references to the subroutines, nor the number of subroutines are hard coded into the script, but are determined at runtime. This will allow me to add additional functions to the list of possible random functions without having to update any other portion of the script. If that is as clear as mud, the code sample below demonstrates what I want to do. I cam...

Merge ginputc function with Display Cursor Location function
I am using this very nice function ginputc http://www.mathworks.com/matlabcentral/fileexchange/38703-custom-ginput/content/ginputc.m That alow me to make zoom pan and other cool stuff. However i also need to be able to get the mouse position and for that there is also this function - Display Cursor Location from here http://www.mathworks.com/matlabcentral/fileexchange/20892 can anyone helpe please merging this Display Cursor Location into the ginputc function please. best regards ...

alarm function
Hi all I'm a newbie in ACE enviroment. I'm making some of the examples found in ACE Tutorial. In particular I'm involved in signal handling. I saw how to register a handler in the reactor. In "normal Unix" programming if I want to wake up a process that can be stoppped calling a blocked function I can use the "alarm" function, like: /* ... */ void *pPrevHandler = (void *)signal (SIGALRM, &mySignalHandler); if (pPrevHandler == SIG_ERR) { printf ("ERR on set SIGALRM\n"); /* error handling */ exit (1); } alarm (SecTmOut); /* possible blocking ...

Which Function to use
Suppose i have UK post codes like this .... For e.g. Ist part of code is HA3 and 2nd part of Code is 9SF. HA3 9SF NW10 1UV A10 7EU N9 14UX Which function i could use so i get the Whole 1st part and Numeric from the 2nd part like below HA3 9 NW10 1 A10 7 N9 14.... Thanks Pareen ...

Initializing a parameter
I have a kind of problem initializing a named constant. If the bugs causing the problem could be fixed it might not do me any good because I won't be able to upgrade the compiler on the target machine any time soon. Here is my problem, with a couple of attempts at workarounds. Can anyone suggest other possibilities given the declarations above that of nada? C:\gfortran\clf\nada>type nada1.f90 program gar_nichts use ISO_C_BINDING use ISO_C_BINDING, only: C_PTR use ISO_C_BINDING, only: abc => C_PTR use ISO_C_BINDING, only: xyz => C_PTR type(abc), para...

Calling a nested function from "outside" main function
Consider a m-file called add.m, which looks like this on the inside: %===== start add.m function m = add .... end function n = plusit .... end function p = minusit .... end %===== end add.m Is there a way for me to call "minusit" from outside add.m? I've looked around and it doesn't look like it's possible but I'd appreciate any input on this. LD ItsLouieD wrote: > Consider a m-file called add.m, which looks like this on the inside: > > %===== start add.m > function m = add > ... > end > > function n = plusi...

How to return values from a java script function
I'd like to write a function 'double_values' which doubles two values. var value1 = 5; var value2 = 20; alert("1) Value 1: " + value1 + " / Value 2: " + value2); double_values(value1, value2); alert("4) Value 1: " + value1 + " / Value 2: " + value2); ... //------------------------------------------------------- function double_values(a, b) { alert("2) A: " + a + " / B: " + b); a = a * 2; b = b * 2; alert("3) A: " + a + " / B: " + b); } Output: 1) Value 1: 5 / V...

Problem with struct pointer in CMEX S-function
Does someone know what is wrong in my c-code bellow. The pointer value is saved and loaded to userdata and the pointer values are correct, but the values in variables are wrong. typedef struct { double W; double D; double Aw; } element; void mdlInitializeConditions { element *cell; cell = mxCalloc(10,sizeof(element)); for(i=0;i<10;i++) { cell[i].W=1; cell[i].D=2; cell[i].Aw=3; } ssSetUserData(S, (element *)cell); } void mdlOutputs { element *cell = ssGetUserData(S); /* at this point the the values cell[i].W=1; cell[i].D=2; */ /* and cell[i].Aw=3; is not correct. The *cell is exa...