Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #13335 > unrolled thread

How to Pass variable name to a function

Started byStan Weiss <srweiss@erols.com>
First post2012-04-11 12:26 -0400
Last post2012-04-12 18:54 -0400
Articles 9 on this page of 29 — 12 participants

Back to article view | Back to comp.lang.javascript


Contents

  How to Pass variable name to a function Stan Weiss <srweiss@erols.com> - 2012-04-11 12:26 -0400
    Re: How to Pass variable name to a function Andreas Bergmaier <andber93@web.de> - 2012-04-11 19:47 +0200
      Re: How to Pass variable name to a function Stan Weiss <srweiss@erols.com> - 2012-04-11 14:21 -0400
        Re: How to Pass variable name to a function Stefan Weiss <krewecherl@gmail.com> - 2012-04-11 20:53 +0200
          Re: How to Pass variable name to a function Stan Weiss <srweiss@erols.com> - 2012-04-11 15:16 -0400
            Re: How to Pass variable name to a function Gene Wirchenko <genew@ocis.net> - 2012-04-11 15:18 -0700
    Re: How to Pass variable name to a function "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-04-11 21:20 +0000
    Re: How to Pass variable name to a function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-04-11 23:56 +0200
      Re: How to Pass variable name to a function Stan Weiss <srweiss@erols.com> - 2012-04-12 00:48 -0400
        Re: How to Pass variable name to a function Andrew Poulos <ap_prog@hotmail.com> - 2012-04-12 15:21 +1000
          Re: How to Pass variable name to a function Stan Weiss <srweiss@erols.com> - 2012-04-12 02:11 -0400
            Re: How to Pass variable name to a function Andrew Poulos <ap_prog@hotmail.com> - 2012-04-12 18:57 +1000
              Re: How to Pass variable name to a function Stan Weiss <srweiss@erols.com> - 2012-04-12 09:35 -0400
        Re: How to Pass variable name to a function Stefan Weiss <krewecherl@gmail.com> - 2012-04-12 08:08 +0200
          Re: How to Pass variable name to a function Stan Weiss <srweiss@erols.com> - 2012-04-12 10:13 -0400
        Re: How to Pass variable name to a function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-04-12 22:47 +0200
          Re: How to Pass variable name to a function Stan Weiss <srweiss@erols.com> - 2012-04-12 17:04 -0400
            Re: How to Pass variable name to a function Tim Streater <timstreater@greenbee.net> - 2012-04-12 22:17 +0100
            Re: How to Pass variable name to a function Scott Sauyet <scott.sauyet@gmail.com> - 2012-04-13 05:13 -0700
              Re: How to Pass variable name to a function "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-04-13 16:27 +0000
                Re: How to Pass variable name to a function Scott Sauyet <scott.sauyet@gmail.com> - 2012-04-16 04:11 -0700
          Re: How to Pass variable name to a function "Tom de Neef" <tdeneef@qolor.nl> - 2012-04-12 23:34 +0200
            Re: How to Pass variable name to a function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-04-13 10:03 +0200
            Re: How to Pass variable name to a function Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-04-13 12:03 +0200
              Re: How to Pass variable name to a function Andrew Poulos <ap_prog@hotmail.com> - 2012-04-13 21:35 +1000
              Re: How to Pass variable name to a function Gene Wirchenko <genew@ocis.net> - 2012-04-13 09:00 -0700
    Re: How to Pass variable name to a function Stan Weiss <srweiss@erols.com> - 2012-04-12 14:03 -0400
    Re: How to Pass variable name to a function Dr J R Stockton <reply1215@merlyn.demon.co.uk.not.invalid> - 2012-04-12 20:06 +0100
      Re: How to Pass variable name to a function Stan Weiss <srweiss@erols.com> - 2012-04-12 18:54 -0400

Page 2 of 2 — ← Prev page 1 [2]


#13406

FromScott Sauyet <scott.sauyet@gmail.com>
Date2012-04-16 04:11 -0700
Message-ID<266ef194-ba3d-47b1-b876-6c85b94394f6@f37g2000yqc.googlegroups.com>
In reply to#13368
Evertjan wrote:
> Scott Sauyet wrote:
>> [ ... ]  Thomas offered nine detailed points, all
>> of which were on-topic, well-stated, and non-argumentative, and a
>> summary which was perhaps condescending but not terribly insulting.
>
> I agree with all this, except the "non-argumentative".
>
> What do you mean by "non-argumentative", my dear Watson?

[ ... definitions of "argument" elided ... ]

| argumentative:
| 1. given to arguing; contentious
| 2. characterized by argument; controversial

His answers were simply helpful explanations of what was wrong in the
code under question.  Except for his summary, nothing attacked the OP
or tried to refute other points of view.

  -- Scott

[toc] | [prev] | [next] | [standalone]


#13359

From"Tom de Neef" <tdeneef@qolor.nl>
Date2012-04-12 23:34 +0200
Message-ID<4f874a80$0$6969$e4fe514c@news2.news.xs4all.nl>
In reply to#13356
"Thomas 'PointedEars' Lahn" <PointedEars@web.de> schreef in bericht 
news:1399313.AFRqVoOGUt@PointedEars.de...
> Stan Weiss wrote:
>
>> Thomas 'PointedEars' Lahn wrote:
>>> [Full quote]
>>
>> Is this a moderated group?
>> Are you the group moderator?
>>
>> I poster enough code to get the answer I needed. While you seem to want
>> to make all kinds of ASSumptions about things that were not posted.
>>
>> Thanks for looking
>>
>> Stan
>>
>> PS Some old habits - presentational attributes (like `align') go back to
>> when I used to do this back in 1997. You know what people tell me that
>> those old scripts still work great.
>
> Could someone please remind me that I never again invest free time into
> replying to such a posting?  TIA.

I always pick useful things up from your posts. Pls don't stop them.
Tom

[toc] | [prev] | [next] | [standalone]


#13363

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2012-04-13 10:03 +0200
Message-ID<1399505.AFRqVoOGUt@PointedEars.de>
In reply to#13359
Tom de Neef wrote:

> "Thomas 'PointedEars' Lahn" [wrote]:
>> Could someone please remind me that I never again invest free time into
>> replying to such a posting?  TIA.
> 
> I always pick useful things up from your posts. Pls don't stop them.

Thank you.


Regards,

PointedEars
-- 
When all you know is jQuery, every problem looks $(olvable).

[toc] | [prev] | [next] | [standalone]


#13364

FromErwin Moller <erwinmollerusenet@xs4all.nl>
Date2012-04-13 12:03 +0200
Message-ID<4f87f9df$0$6978$e4fe514c@news2.news.xs4all.nl>
In reply to#13359
On 4/12/2012 11:34 PM, Tom de Neef wrote:
> "Thomas 'PointedEars' Lahn"<PointedEars@web.de>  schreef in bericht
> news:1399313.AFRqVoOGUt@PointedEars.de...
>> Stan Weiss wrote:
>>
>>> Thomas 'PointedEars' Lahn wrote:
>>>> [Full quote]
>>>
>>> Is this a moderated group?
>>> Are you the group moderator?
>>>
>>> I poster enough code to get the answer I needed. While you seem to want
>>> to make all kinds of ASSumptions about things that were not posted.
>>>
>>> Thanks for looking
>>>
>>> Stan
>>>
>>> PS Some old habits - presentational attributes (like `align') go back to
>>> when I used to do this back in 1997. You know what people tell me that
>>> those old scripts still work great.
>>
>> Could someone please remind me that I never again invest free time into
>> replying to such a posting?  TIA.
>
> I always pick useful things up from your posts. Pls don't stop them.
> Tom

Just a "me too".
Once one has learned to survive his "poetry" by gnawing one's own legs 
off, his contributions can be quite useful and instructive.
I always read them.

Regards,
Erwin Moller


-- 
"That which can be asserted without evidence, can be dismissed without 
evidence."
-- Christopher Hitchens

[toc] | [prev] | [next] | [standalone]


#13365

FromAndrew Poulos <ap_prog@hotmail.com>
Date2012-04-13 21:35 +1000
Message-ID<CZKdndGJmuECkhXSnZ2dnUVZ_tadnZ2d@westnet.com.au>
In reply to#13364
On 13/04/2012 8:03 PM, Erwin Moller wrote:
> On 4/12/2012 11:34 PM, Tom de Neef wrote:
>> "Thomas 'PointedEars' Lahn"<PointedEars@web.de> schreef in bericht
>> news:1399313.AFRqVoOGUt@PointedEars.de...
>>> Stan Weiss wrote:
>>>
>>>> Thomas 'PointedEars' Lahn wrote:
>>>>> [Full quote]
>>>>
>>>> Is this a moderated group?
>>>> Are you the group moderator?
>>>>
>>>> I poster enough code to get the answer I needed. While you seem to want
>>>> to make all kinds of ASSumptions about things that were not posted.
>>>>
>>>> Thanks for looking
>>>>
>>>> Stan
>>>>
>>>> PS Some old habits - presentational attributes (like `align') go
>>>> back to
>>>> when I used to do this back in 1997. You know what people tell me that
>>>> those old scripts still work great.
>>>
>>> Could someone please remind me that I never again invest free time into
>>> replying to such a posting? TIA.
>>
>> I always pick useful things up from your posts. Pls don't stop them.
>> Tom
>
> Just a "me too".
> Once one has learned to survive his "poetry" by gnawing one's own legs
> off, his contributions can be quite useful and instructive.
> I always read them.

Yeah, and PE does *not* say things like "poorly written code was good 
enough for my great grandfather so its good enough for me" ;-)

Andrew Poulos

[toc] | [prev] | [next] | [standalone]


#13367

FromGene Wirchenko <genew@ocis.net>
Date2012-04-13 09:00 -0700
Message-ID<gbjgo7hrs4dlm27k16ies7922itbmgjhu7@4ax.com>
In reply to#13364
On Fri, 13 Apr 2012 12:03:13 +0200, Erwin Moller
<erwinmollerusenet@xs4all.nl> wrote:

[snip]

>Just a "me too".
>Once one has learned to survive his "poetry" by gnawing one's own legs 
>off, his contributions can be quite useful and instructive.
>I always read them.

     I walk an hour most days for cardio.  I need my legs.  YMMV, and
will, if you have no legs and I do.

Sincerely,

Gene Wirchenko

[toc] | [prev] | [next] | [standalone]


#13355

FromStan Weiss <srweiss@erols.com>
Date2012-04-12 14:03 -0400
Message-ID<4F8718D5.170C97BC@erols.com>
In reply to#13335
Thank to all that posted for your help.

1) The reason for only posting code snippets was that form does
calculation of someone else's equations which I could not share.

2) This is fully functional and working but used method which were not
generalized. That was the reason for the inquiry

This is what I have now.

function numeric( field, fallback, name ) {
     var num = parseFloat(field);
     if (isNaN(field)) {
         alert(name + " is not numeric");
         return fallback;
     } else
         return num;
}

<TR><TD ALIGN="RIGHT">
<b>Valve Diameter in Millimetres </b>
</TD><TD>
<INPUT TYPE="text" NAME="VD" SIZE=7  onChange="AInput =
numeric(this.value, AInput, 'Valve Diameter')">
</TD></TR>

When I have more time I will look into implementing what Stefan
suggested about replacing the "isNaN"

Thanks again,

Stan

[toc] | [prev] | [next] | [standalone]


#13360

FromDr J R Stockton <reply1215@merlyn.demon.co.uk.not.invalid>
Date2012-04-12 20:06 +0100
Message-ID<Aj8fxRPNfyhPFwNo@invalid.uk.co.demon.merlyn.invalid>
In reply to#13335
In comp.lang.javascript message <4F85B0AE.A1E9FFD8@erols.com>, Wed, 11
Apr 2012 12:26:22, Stan Weiss <srweiss@erols.com> posted:

>I have this code in a form which calls the save function.
>
><TR><TD ALIGN="RIGHT">
><b>Valve Diameter in Millimetres </b>
></TD><TD>
><INPUT TYPE="text" NAME="VD" SIZE=7  onChange="save(stanForm.VD.value,
>AInput, 'Valve Diameter')">
></TD></TR>
>
>function save( field, vary, text ) {
>     if( isNaN( field ) )
>     {
>        alert( text + " is not numeric" );
>     }
>     else
>     {
>         AInput = eval(field);  // this Works
>         vary = eval(field);    // this does not workWorks
>     }
>}
>
>Can anyone see what I am doing wrong?

Easily :
  You are not saying which browser you have been using.
  You have not posted complete working/failing code.
  You have not reported the output (including "none") of the browser's
    native, or another, debugger.
  You've not remembered things said in the newsgroup FAQ.
  You've not said exactly what you expect, nor what you get - that code
    works as it should, only your expectations were wrong.
  And, as a minor detail, your code is wrong.

To convert a typed input String to a Number, unary + is commonly best;
neither too liberal nor too rigorous.  For example, AInput = +field .
Then check that the value of AInput is admissible.

                                And, posting from -0400, should you
                                be spelling Millimetres correctly ?

-- 
 (c) John Stockton, nr London UK  ?@merlyn.demon.co.uk  IE8 FF8 Op11 Sf5 Cr15
   news:comp.lang.javascript FAQ <http://www.jibbering.com/faq/index.html>.
   <http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
   <http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

[toc] | [prev] | [next] | [standalone]


#13361

FromStan Weiss <srweiss@erols.com>
Date2012-04-12 18:54 -0400
Message-ID<4F875D37.78BE0EBE@erols.com>
In reply to#13360

Dr J R Stockton wrote:
> 
> In comp.lang.javascript message <4F85B0AE.A1E9FFD8@erols.com>, Wed, 11
> Apr 2012 12:26:22, Stan Weiss <srweiss@erols.com> posted:
> 
> >I have this code in a form which calls the save function.
> >
> ><TR><TD ALIGN="RIGHT">
> ><b>Valve Diameter in Millimetres </b>
> ></TD><TD>
> ><INPUT TYPE="text" NAME="VD" SIZE=7  onChange="save(stanForm.VD.value,
> >AInput, 'Valve Diameter')">
> ></TD></TR>
> >
> >function save( field, vary, text ) {
> >     if( isNaN( field ) )
> >     {
> >        alert( text + " is not numeric" );
> >     }
> >     else
> >     {
> >         AInput = eval(field);  // this Works
> >         vary = eval(field);    // this does not workWorks
> >     }
> >}
> >
> >Can anyone see what I am doing wrong?
> 
> Easily :
>   You are not saying which browser you have been using.
>   You have not posted complete working/failing code.
>   You have not reported the output (including "none") of the browser's
>     native, or another, debugger.
>   You've not remembered things said in the newsgroup FAQ.
>   You've not said exactly what you expect, nor what you get - that code
>     works as it should, only your expectations were wrong.
>   And, as a minor detail, your code is wrong.
> 
> To convert a typed input String to a Number, unary + is commonly best;
> neither too liberal nor too rigorous.  For example, AInput = +field .
> Then check that the value of AInput is admissible.
> 
>                                 And, posting from -0400, should you
>                                 be spelling Millimetres correctly ?

There are a few word spelled that way since the original code was
written by someone in
the UK. I am changing the User Interface. Here in the US I would have
used inches. <g> I mean "Atmospheric Pressure Reading in Millibars" or
"Vapour Pressure" <lol>

Stan

> 
> --
>  (c) John Stockton, nr London UK  ?@merlyn.demon.co.uk  IE8 FF8 Op11 Sf5 Cr15
>    news:comp.lang.javascript FAQ <http://www.jibbering.com/faq/index.html>.
>    <http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
>    <http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.javascript


csiph-web