Re: a quick js code question

  • From: "Jeffrey Fidler" <jfiddler2@xxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Wed, 6 Feb 2008 22:32:08 -0500

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 //www.freelists.org/list/programmingblind




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

Other related posts: