473,509 Members | 2,890 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get rid of 'eval'

This is a question to those who mean 'eval is evil'. I'm one of those.
However, I cannot answer my question. ;-)

Have a look at this page

http://home.arcor.de/pil/show-gallery.html?p=clouds

You'll notice that a parameter is passed through the URL. This is
necessary to choose the appropriate picture category. Therefore there
are three or four 'eval' inside the script.

The question is: How can this be done without 'eval'?

Oct 6 '08 #1
5 1564
Mon, 6 Oct 2008 08:57:06 -0700 (PDT), /Proper/:
Have a look at this page

http://home.arcor.de/pil/show-gallery.html?p=clouds

You'll notice that a parameter is passed through the URL. This is
necessary to choose the appropriate picture category. Therefore there
are three or four 'eval' inside the script.

The question is: How can this be done without 'eval'?
eval('pics.'+ category +'.length') == pics[category].length

eval('pics.'+ category +'[nr].path') == pics[category][nr].path

--
Stanimir
Oct 6 '08 #2
Stanimir Stamenkov wrote:
Mon, 6 Oct 2008 08:57:06 -0700 (PDT), /Proper/:
>Have a look at this page

http://home.arcor.de/pil/show-gallery.html?p=clouds

You'll notice that a parameter is passed through the URL. This is
necessary to choose the appropriate picture category. Therefore there
are three or four 'eval' inside the script.

The question is: How can this be done without 'eval'?

eval('pics.'+ category +'.length') == pics[category].length

eval('pics.'+ category +'[nr].path') == pics[category][nr].path
Right.

The question is also answered in the FAQ:
http://jibbering.com/faq/#propertyAccess
http://jibbering.com/faq/#eval

Also see:
http://www.jibbering.com/faq/faq_not..._brackets.html
Oct 7 '08 #3
On Oct 7, 4:36 am, dhtml wrote:
<snip>
The question is also answered in the FAQ:
http://jibbering.com/faq/#propertyAccess
<snup ^^^^^^^^^^^^^^^

These fragment identifiers are non-functional in IE 6. As IE 6 is
still in common use you should either correct them so that they are
functional or abandon using them.
Oct 7 '08 #4
In comp.lang.javascript message <c3023857-d4bc-4b35-868c-39b544845219@f7
7g2000hsf.googlegroups.com>, Tue, 7 Oct 2008 02:46:43, Henry
<rc*******@raindrop.co.ukposted:
>On Oct 7, 4:36 am, dhtml wrote:
<snip>
>The question is also answered in the FAQ:
http://jibbering.com/faq/#propertyAccess
<snup ^^^^^^^^^^^^^^^

These fragment identifiers are non-functional in IE 6. As IE 6 is
still in common use you should either correct them so that they are
functional or abandon using them.
Would http://jibbering.com/faq/index.html#propertyAccess be
functional in IE6 etc.?; memory suggests yes.

--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.

Usenet News services are currently unreliable; I may not see all articles here.
Oct 7 '08 #5
On Oct 7, 5:36 am, dhtml <dhtmlkitc...@gmail.comwrote:
Also see:
http://www.jibbering.com/faq/faq_not..._brackets.html
Thanks guys, especially for this article
:-)

I'll leave my example from above untouched as an example for 'evil
eval'.
Oct 7 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
4081
by: Reply Via Newsgroup | last post by:
This might sound sad... someone requesting a disertation on the 'eval' statement... but... I've been reading someone else's post - they had a huge calander like script and a handful of folk cursed...
11
1843
by: sneill | last post by:
I have read a number of posts on the use of eval() in Javascript, and I agree that its use is questionable. But it does beg the following question: "How arbitrary does a string need to be before...
0
3803
by: Michelle Keys | last post by:
Subject: DataBinder.Eval Error! Server Error in '/MSPOS' Application. ------------------------------------------------------------------------ -------- DataBinder.Eval:...
18
3138
by: Joe Fallon | last post by:
I have some complex logic which is fairly simply to build up into a string. I needed a way to Eval this string and return a Boolean result. This code works fine to achieve that goal. My...
15
3642
by: manstey | last post by:
Hi, I have a text file called a.txt: # comments I read it using this:
3
1893
by: Pauljh | last post by:
Hi All, I'm running some javascript over a server side generated web page and have multiple generated empty select statements, that I want to populate when the page is loaded. As HTML doesn't do...
4
2758
by: Jm lists | last post by:
Hello members, I want to know does the "eval" in python have the same features as in Perl (capture errors)? For example,in perl I can wrote: $re = eval { 1 / 0 }; Though 1/0 is a fatal...
6
5883
by: RandomElle | last post by:
Hi there I'm hoping someone can help me out with the use of the Eval function. I am using Access2003 under WinXP Pro. I can successfully use the Eval function and get it to call any function with...
5
6618
by: wendallsan | last post by:
Hi all, I'm running into a situation where it seems that JS stops executing as soon as I call an eval in my script. I have an Ajax.Request call to a PHP page that builds a JS object and returns...
10
494
by: Gordon | last post by:
I have a script that creates new objects based on the value of a form field. Basically, the code looks like this. eval ('new ' + objType.value + '(val1, val2, val3'); objType is a select with...
0
7136
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7412
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5652
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3216
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3203
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1570
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.