resolved: RE: a quick js code question

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 type
back from
the form.ihn.value property, and then you are passing it to
eval(), which
then will evaluate the string as if it is an expression.  (This
is one of
the things I find troubling about loosely typed languages!  You
have to
manage all of the data typing in your head instead of knowing it
explicitly
by glancing at the code.)  That is why you will get '13' out of
the value
property and 4 out of eval().  In any case, one of the oldest
debugging
techniques in the javascript world is to insert an alert()
function call her
and there to see what you are getting out of your assignments.
If you find
that alert(x); returns 'undefined' or something strange like
that, you will
have 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 using
eval()
causes 1+3 to equal 13, while using eval() gives me 4, which is
the type
of 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 use
the
assignment 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 to
run.  I have
this function being called by a button and that part works, but
I cannot
get an answer out of this function.  It seems to stop at where I
declare x
as a variable.  The code, all 12 lines of it, is below.  If
anyone can
point 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
http://www.freelists.org/list/programmingblind




__________
View the list's information and change your settings at
http://www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at
http://www.freelists.org/list/programmingblind




__________
View the list's information and change your settings at
http://www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at
http://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
http://www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at http://www.freelists.org/list/programmingblind

Other related posts:

  • » resolved: RE: a quick js code question