Path: csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: Stan Weiss Newsgroups: comp.lang.javascript Subject: Re: How to Pass variable name to a function Date: Thu, 12 Apr 2012 18:54:47 -0400 Organization: Aioe.org NNTP Server Lines: 61 Message-ID: <4F875D37.78BE0EBE@erols.com> References: <4F85B0AE.A1E9FFD8@erols.com> NNTP-Posting-Host: 0LFKx0y469vyintJTg0+6A.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Mailer: Mozilla 4.8 [en] (Windows NT 5.0; U) X-Accept-Language: en X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.javascript:13361 Dr J R Stockton wrote: > > In comp.lang.javascript message <4F85B0AE.A1E9FFD8@erols.com>, Wed, 11 > Apr 2012 12:26:22, Stan Weiss posted: > > >I have this code in a form which calls the save function. > > > > > >Valve Diameter in Millimetres > > > > > > > > > >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. I mean "Atmospheric Pressure Reading in Millibars" or "Vapour Pressure" Stan > > -- > (c) John Stockton, nr London UK ?@merlyn.demon.co.uk IE8 FF8 Op11 Sf5 Cr15 > news:comp.lang.javascript FAQ . > jscr maths, dates, sources. > TP/BP/Delphi/jscr/&c, FAQ items, links.