That did it! I changed the text field called "in" to "val" and it works beautifully. Thanks. Why would js care that the field was called "in"?
Have a great day, Alex
----- Original Message ----- From: "Adrian Beech" <a.beech@xxxxxxxxxxxxxx To: <programmingblind@xxxxxxxxxxxxx Date sent: Thu, 7 Feb 2008 23:46:03 +1000 Subject: RE: a quick js code question
G'day,
Change the name of the "in" field to something else, i.e.
"inVal". I also
assume your form is named "form"? I'd change this too to
something else as
well.
Cheers. AB
-----Original Message----- From: programmingblind-bounce@xxxxxxxxxxxxx[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Alex
Hall
Sent: Thursday, 7 February 2008 10:42 PM To: programmingblind@xxxxxxxxxxxxx Subject: Re: a quick js code question
I have tried alerting x but nothing happens, and I mean nothing; no alert, no error alert, there is just a small pause as though my bn were running the function but then nada.
Have a great day, Alex
----- Original Message ----- From: "Jeffrey Fidler" <jfiddler2@xxxxxxxxxxx To: <programmingblind@xxxxxxxxxxxxx Date sent: Wed, 6 Feb 2008 23:01:59 -0500 Subject: Re: a quick js code question
Alex,
When you are initializing x, you are first getting a string typeback fromthe form.ihn.value property, and then you are passing it toeval(), whichthen will evaluate the string as if it is an expression. (Thisis one ofthe things I find troubling about loosely typed languages! Youhave tomanage all of the data typing in your head instead of knowing itexplicitlyby glancing at the code.) That is why you will get '13' out ofthe valueproperty and 4 out of eval(). In any case, one of the oldestdebuggingtechniques in the javascript world is to insert an alert()function call herand there to see what you are getting out of your assignments.If you findthat alert(x); returns 'undefined' or something strange likethat, you willhave a place to begin working toward a solution to your problem.
Good luck!
- Jeff
----- Original Message ----- From: "Alex Hall" <mehgcap@xxxxxxx To: <programmingblind@xxxxxxxxxxxxx Sent: Wednesday, February 06, 2008 10:49 PM Subject: Re: a quick js code question
Yes, I tried it both ways. I have found, though, that not usingeval()causes 1+3 to equal 13, while using eval() gives me 4, which isthe typeof answer I am looking for.
Have a great day, Alex
----- Original Message ----- From: "Jeffrey Fidler" <jfiddler2@xxxxxxxxxxx To: <programmingblind@xxxxxxxxxxxxx Date sent: Wed, 6 Feb 2008 22:32:08 -0500 Subject: Re: a quick js code question
Alex,
eval() will evaluate a string argument. Did you try to just usetheassignment operator to initialize your variable? i.e. var x = form.in.value;
HTH!
- Jeff
----- Original Message ----- From: "Alex Hall" <mehgcap@xxxxxxx To: <programmingblind@xxxxxxxxxxxxx Sent: Wednesday, February 06, 2008 10:08 PM Subject: a quick js code question
Hi all, I have a very simple program that, for some reason refuses torun. I havethis function being called by a button and that part works, butI cannotget an answer out of this function. It seems to stop at where Ideclare xas a variable. The code, all 12 lines of it, is below. Ifanyone canpoint out what I know must be a very simple error I would really appreciate it. function eq(){ try{ x=eval(form.in.value); ans=(x-2)/(x*x)-4; form.out.value=ans;
catch(err){ alert(err+": "+err.description);
Have a great day, Alex __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind
__________ View the list's information and change your settings at //www.freelists.org/list/programmingblind
__________ View the list's information and change your settings at //www.freelists.org/list/programmingblind
__________ View the list's information and change your settings at //www.freelists.org/list/programmingblind
__________ View the list's information and change your settings at //www.freelists.org/list/programmingblind
__________ NOD32 2855 (20080207) Information __________
This message was checked by NOD32 antivirus system. http://www.eset.com
__________ View the list's information and change your settings at //www.freelists.org/list/programmingblind
__________View the list's information and change your settings at //www.freelists.org/list/programmingblind