what does eval function do in javascript language and what are its
usages? 6 2512
On Mon, 13 Dec 2004 07:30:56 GMT, Dag Sunde <me@dagsunde.co m> wrote: <am******@hotma il.com> wrote in message news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
what does eval function do in javascript language and what are its usages?
RTFM...
http://developer.netscape.com/librar...avascript.html
However, that manual doesn't exist any more. :P
<URL:http://docs.sun.com/source/816-6408-10/toplev.htm#1063 795>
Basically, it allows you to construct and run statements at run-time.
However, there are *very* few instances where you actually need to use
eval; there are usually much better ways of accomplishing the same thing.
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
<amoha...@hotma il.com> wrote: what does eval function do in javascript language and what are its usages?
Here is an example usage. Let's say I have several drop-down menu and
certain buttons/events that require all items in the dropdown be
highlighted. Here is a thrown-together example of a highlight
function:
function selectAll(dd) {
eval('var box=document.fo rm.'+dd);
for (var i=0;i<box.optio ns.length;i++) { box.options[i].selected=true;
}
}
In this example, "eval('var box=document.fo rm.'+dd);" would evaluate to
"var box=document.fo rm.myDropDown". Now, if a user clicked a button
and I wanted it to highlight all the fields in the dropdown named
'myDropDown', you could use something like this:
<button onclick="select All('myDropDown ')" />Highlight Dropdown
#1</button>
This is especially useful for dynamically created controls that may
have dynamic names.
Daniel M. Hendricks http://www.danhendricks.com
On 13 Dec 2004 07:11:06 -0800, "Daniel M. Hendricks"
<dm*********@de spammed.com> wrote: <amoha...@hotm ail.com> wrote:
what does eval function do in javascript language and what are its usages?
Here is an example usage.
This is especially useful for dynamically created controls that may have dynamic names.
Maybe you should read the FAQ, before giving any more answers, just in
case the correct answer is there...
Jim.
JRS: In article <Qy************ *******@juliett .dax.net>, dated Mon, 13
Dec 2004 07:30:56, seen in news:comp.lang. javascript, Dag Sunde
<me@dagsunde.co m> posted : <am******@hotm ail.com> wrote in message news:11******* *************** @z14g2000cwz.go oglegroups.com. .. what does eval function do in javascript language and what are its usages? http://developer.netscape.com/librar...avascript.html
But also newsgroup FAQ sec 4.40.
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
>>what does eval function do in javascript language and what are its usages?
Here is an example usage. Let's say I have several drop-down menu and certain buttons/events that require all items in the dropdown be highlighted. Here is a thrown-together example of a highlight function:
function selectAll(dd) { eval('var box=document.fo rm.'+dd); for (var i=0;i<box.optio ns.length;i++) { box.options[i].selected=true; } }
In this example, "eval('var box=document.fo rm.'+dd);" would evaluate to "var box=document.fo rm.myDropDown".
The only advantage to using eval in this way is that it might allow a
very slow-witted scripter to avoid learning about the subscript notation.
function selectAll(dd) {
var box = document.form[dd];
It is almost always wrong to use the eval function. http://www.crockford.com/javascript/survey.html This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jean-Sébastien Bolduc |
last post by:
Hello,
I would like to associate a local namespace with a lambda function. To
be more specific, here is exactly what I would want:
def foo():
a = 1
f = lambda x : a*x
return f
|
by: HikksNotAtHome |
last post by:
This is a very simplified example of an Intranet application. But, is there an
easier (or more efficient) way of getting the decimal equivalent of a fraction?
The actual function gets the select values, this one is a simplified version
where its passed.
function checkIt(selVal){
valueInDec1 = eval(selVal);
//do some calculations here with valueInDec1
}
|
by: knocte |
last post by:
Hello.
I have always thought that the eval() function was very flexible and
useful. If I use it, I can define functions at runtime!!
However, I have found a case where eval() does not work properly. It
works, for example, when invoking functions (alert('hello')), but not
for defining functions.
The case occurs when retrieving the javascript code with
|
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 question is what happens to the dynamically created assembly when the
method is done running? Does GC take care of it?
Or is it stuck in RAM until the ASP.Net process is recycled?
This code executes pretty frequently (maybe 4 times per transaction) and...
|
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 arrays each
select is individually named withe MySelecti where i is an incremental
from 1.
I know all my variables are correct (i, OptionsCount) and my arrays
of MyValues and MyDescription's exist for multiple enteries and if I
bring out an...
| |
by: Darko |
last post by:
Hello,
I have this particular problem with eval() when using Microsoft
Internet Explorer, when trying to define an event handler. This is the
code:
function BigObject()
{
this.items = new Array();
this.values = new Array();
|
by: vasudevram |
last post by:
Hi group,
Question: Do eval() and exec not accept a function definition? (like
'def foo: pass) ?
I wrote a function to generate other functions using something like
eval("def foo: ....")
but it gave a syntax error ("Invalid syntax") with caret pointing to
the 'd' of the def keyword.
|
by: Florian Loitsch |
last post by:
hi,
What should be the output of the following code-snippet?
===
var x = "global";
function f() {
var x = 0;
eval("function x() { return false; }");
delete x;
alert(x);
}
|
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 or without parms. I know that any function that is passed to Eval() must be declared Public. It can be a Sub or Function, as long as it's Public. I even have it where the "function" evaluated by Eval can be in a form (class) module or in a standard...
|
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 the different types of objects you can create
as values.
I really don't like using eval, and it's causing problems, like if I
do something like the following:
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
| |