473,612 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Alternative to eval

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
}

<select onchange="check It(this.value)" >
<option value="0">0</option>
<option value="1/16">1/16</option>
<option value="1/8">1/8</option>
...............
<option value="7/8">7/8</option>
<option value="15/16">15/16</option>
</select>

I know that I could change it and have it look up the decimal equivalent for
the fraction, with an Object or an Array. I could also split the value on the /
and convert them to numbers, do the division, and get the decimal.

I discounted the Object/Array approach (and may go back to it, but doubt it).
The reason is that its not just 16ths. Some of the selects are 37ths, some are
7ths, one of them has 128ths in it. Simply put, I don't think that maintaining
10+ objects to contain the decimals is efficient (but open to that approach).
Also, its subject to get some added (different denominators), and some removed.

The split approach just doesn't seem to be as efficient though.

function checkIt(selVal) {
myNumber = selVal.split('/')
decimalForm = parseFloat(myNu mber[0])/parseFloat(myNu mber[1])
//do some calculations here with valueInDec1
}

When the form gets submitted, it has to be in fractional form. I have no
control over the way the selects get generated so I am kind of stuck trying to
do it client side.

Thoughts, suggestions, comments?
--
Randy
All code posted is dependent upon the viewing browser
supporting the methods called, and Javascript being enabled.
Jul 20 '05 #1
9 8457
Lee
HikksNotAtHome said:

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
}

<select onchange="check It(this.value)" >
<option value="0">0</option>
<option value="1/16">1/16</option>
<option value="1/8">1/8</option>
............ ..
<option value="7/8">7/8</option>
<option value="15/16">15/16</option>
</select>

The most efficient solution would seem to be:

<select onchange="check It(this.value)" >
<option value="0">0</option>
<option value="0.0625"> 1/16</option>
<option value="0.125">1/8</option>
...............
<option value="0.875">7/8</option>
<option value="0.9375"> 15/16</option>
</select>

Jul 20 '05 #2
In article <bh*********@dr n.newsguy.com>, Lee <RE************ **@cox.net>
writes:
The most efficient solution would seem to be:

<select onchange="check It(this.value)" >
<option value="0">0</option>
<option value="0.0625"> 1/16</option>
<option value="0.125">1/8</option>
............ ..
<option value="0.875">7/8</option>
<option value="0.9375"> 15/16</option>
</select>


I agree with you 100%. I have no control over how the select is generated
though. If I loop through the select and options and programatically change
them to decimals, I have to convert them back to fractions (or, swap them with
the text of the option) so that when the form gets submitted, I get the
fraction instead of the decimal. The eval still seems to be more efficient
though, in the end. ::sigh::
--
Randy
All code posted is dependent upon the viewing browser
supporting the methods called, and Javascript being enabled.
Jul 20 '05 #3
On 17 Aug 2003 17:55:11 GMT, hi************@ aol.com (HikksNotAtHome )
wrote:
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?

I know that I could change it and have it look up the decimal equivalent for
the fraction, with an Object or an Array. I could also split the value on the /
and convert them to numbers, do the division, and get the decimal.

I discounted the Object/Array approach (and may go back to it, but doubt it).
The reason is that its not just 16ths. Some of the selects are 37ths, some are
7ths, one of them has 128ths in it. Simply put, I don't think that maintaining
10+ objects to contain the decimals is efficient (but open to that approach).
Also, its subject to get some added (different denominators), and some removed.

The split approach just doesn't seem to be as efficient though.

function checkIt(selVal) {
myNumber = selVal.split('/')
decimalForm = parseFloat(myNu mber[0])/parseFloat(myNu mber[1])
//do some calculations here with valueInDec1
}

When the form gets submitted, it has to be in fractional form.


The Object/Array approach involves a fair bit of overhead, either in
download time if all the contents are hardcoded, or time if they are
generated at some point.

As far as parsing the string goes, I've always considered compiled
code to be faster than script-based parsing; split may not do as bad
as you think.

Usually I recommend against using eval because there is almost always
a clearly better way of accomplishing the goal, but in this case I
suspect eval will be equal to or better than any other method, plus,
it appears that the input strings are static, so I think eval is the
way to go.

Regards,
Steve
Jul 20 '05 #4
"HikksNotAtHome " <hi************ @aol.com> wrote in message
news:20******** *************** ****@mb-m21.aol.com...
<snip>
function checkIt(selVal) {
valueInDec1 = eval(selVal);
//do some calculations here with valueInDec1
}
If you just want to avoid the word "eval" appearing in your source code
you could use:-

valueInDec1 = new Function ('return ('+selVal+');') ();

- but that will perform worse that eval. And the Function constructor
will probably use eval internally so it is really no more than avoiding
eval by name.

<snip> function checkIt(selVal) {
myNumber = selVal.split('/')
decimalForm = parseFloat(myNu mber[0])/parseFloat(myNu mber[1])
//do some calculations here with valueInDec1
}


Unary + is about 4 times faster at string to number conversion than
parseFloat, so:-

decimalForm = (+myNumber[0])/(+myNumber[1]);

-should be fractionally quicker. But then the division operator requires
numeric operands so it will type-convert anyway so just:-

decimalForm = (myNumber[0]/myNumber[1]);

- will do.

Generally I can't think of a non-eval approach that is better than the
split-and-divide function above.

Richard.
Jul 20 '05 #5
In article <bh************ *******@news.de mon.co.uk>, "Richard Cornford"
<Ri*****@litote s.demon.co.uk> writes:
Unary + is about 4 times faster at string to number conversion than
parseFloat, so:-

decimalForm = (+myNumber[0])/(+myNumber[1]);

-should be fractionally quicker. But then the division operator requires
numeric operands so it will type-convert anyway so just:-

decimalForm = (myNumber[0]/myNumber[1]);
The difference I see, in testing, of these two:

decimalForm = (myNumber[0]/myNumber[1]);
decimalForm = parseFloat(myNu mber[0])/parseFloat(myNu mber[1])

Is in the 50-60 ms range, on 400-500 ms, The more passes, the stranger the
results get.
- will do.

Generally I can't think of a non-eval approach that is better than the
split-and-divide function above.


Changing the test that I posted to
decimalForm = (myNumber[0]/myNumber[1]);
instead of the parseFloat's, I still get 440-500 milliseconds on 10,000 passes.

I do see a difference with/without the parseFloat though (about 50-60
milliseconds on 10,000 passes).

With eval, I get in the range of 110 - 220. Which actually makes eval faster
than the split/divide method in any form.

Upping it to 50,000 passes, I get these results:

Test1:
eval took 1100 milliseconds
split took 8070 milliseconds
split with parseFloat took 8020 milliseconds
split with parseInt took 8020 milliseconds

Test2:
eval took 1050 milliseconds
split took 7960 milliseconds
split with parseFloat took 8020 milliseconds
split with parseInt took 8180 milliseconds

Test3:
eval took 1090 milliseconds
split took 7910 milliseconds
split with parseFloat took 8080 milliseconds
split with parseInt took 8020 milliseconds

Test4:
eval took 550 milliseconds
split took 7860 milliseconds
split with parseFloat took 7960 milliseconds
split with parseInt took 7970 milliseconds

Test5:
eval took 1040 milliseconds
split took 8130 milliseconds
split with parseFloat took 8020 milliseconds
split with parseInt took 8130 milliseconds

The test page I used can be found at:
<URL: http://members.aol.com/hikksnotathom...est/index.html />
Its set at 50,000 passes, view-source: may be a better way to get to it than
letting it potentially lock up a browser.
I added a 4th test, using parseInt instead of parseFloat, just for
kicks/giggles.

I had a new Function test in it but it was killing it, 11,000+ milliseconds (as
you guessed it would do), so I took it out.

But I wasn't avoiding eval for the sake of avoiding it. When I first tried it,
I actually expected it to be slower, and got to looking at it, and thinking
about what it was actually doing, and then started testing it. Saw where eval
was faster, so I wanted other opinions on it. There may even be a flaw in my
test itself?
--
Randy
All code posted is dependent upon the viewing browser
supporting the methods called, and Javascript being enabled.
Jul 20 '05 #6
"HikksNotAtHome " <hi************ @aol.com> wrote in message
news:20******** *************** ****@mb-m06.aol.com...
<snip>
alerts 330 and 500 for me, which indicates eval is faster. But
thats on a 2.2 Ghz Machine with 256mbs Ram. Will test it again
tomorrow at work, on a slower machine, just to see how much
difference it makes. But it can only make a bigger difference.

<snip>

It looks to me like the results vary considerably depending on the
browser. For IE eval is quickest, on Opera 7 and Mozilla 1.3 split
followed by division comes out on top (500 Mhz PIII Win 98).

Taking:-
myNumber = tempObj[c].split('/')
N = myNumber[0]/myNumber[1];
- as the basis for comparison (100% on each browser)
IE = 100%
Op = 100%
Mz = 100%

myNumber = tempObj[c].split('/')
N = (+myNumber[0])/(+myNumber[1]);
IE = 98.74%
Op = 98.36%
Mz = 100%

myNumber = tempObj[c].split('/')
N = parseFloat(myNu mber[0])/parseFloat(myNu mber[1]);
IE = 108.26%
Op = 118.03%
Mz = 109.52%

N = eval(tempObj[i]);
IE = 17.50%
Op = 154.10%
Mz = 122.22%

N = new Function('retur n ('+tempObj[i]+');')();
IE = 163.58%
Op = 286.88%
Mz = 152.38%

For comparison, this is my test page:-

<html>
<head>
<title></title>
<script type="text/javascript">
var frm = null;
var fncts = ['emptyL','evalV ersion','Functi onObject',
'splitNparseFlo at','splitNunar yPlus','splitNd ivide'];
var running = false;

function setButtons(bl){
frm['loopLimit'].disabled = bl;
var sw = frm['bt'];
if(typeof sw.length == 'undefined'){
sw = [sw];
}
for(var c = 0;c < sw.length;c++){
sw[c].disabled = bl;
}
}

var tempObj = new Object();
function doTests(){
if(!running){
var t = ['','/',''];
frm = document.forms['f'].elements;
setButtons(true );
t[2] = +frm['loopLimit'].value;

for (var k=0;k<t[2];k++){
t[0] = k;
tempObj[k]= t.join('');
}
frm["Dur0"].value = '';frm["Avr0"].value = '';
for(var c = 1;c < fncts.length;c+ +){
frm["Dur"+c].value = '';
frm["Avr"+c].value = '';
frm["CAvr"+c].value = '';
frm["PAvr"+c].value = '';
frm["Res"+c].value = '';
}
running = true;
act(0);
}
}
function act(p){
/* setTimeout is used to minimise the occurrences
of 'a script on this page is running slow' dialogs. */
if(p >= fncts.length){
setTimeout('rep ort()',100);
}else{
setTimeout((fnc ts[p]+'('+p+');'),20 0);
}
}
function report(){
var lim = +frm['loopLimit'].value;
var emDur = +frm["Dur0"].value
var unaC = (frm["Dur"+(fncts.le ngth-1)].value - emDur) / lim;
frm["CAvr"+(fncts.l ength-1)].value = unaC;
frm["PAvr"+(fncts.l ength-1)].value = '100';
for(var c = 1;c < (fncts.length-1);c++){
if(frm["Cb"+c].checked){
var evaC = (frm["Dur"+c].value - emDur) / lim;
frm["CAvr"+c].value = evaC;
frm["PAvr"+c].value = ((evaC/unaC)*100);
}else{
frm["CAvr"+c].value = 'X';
frm["PAvr"+c].value = 'X';
}
}
setButtons(fals e);
running = false;
}
function emptyL(p){
var lim = +frm['loopLimit'].value;
var totTime,stTime = new Date().getTime( );
for(var c = 0;c < lim;c++){
;
}
totTime = (new Date().getTime( ) - stTime)
frm["Dur0"].value = totTime;
frm["Avr0"].value = (totTime/lim);
act(p+1);
}
function evalVersion(p){
if(frm['Cb'+p].checked){
var lim = +frm['loopLimit'].value;
var N;
var totTime,stTime = new Date().getTime( );
for(var c = 0;c < lim;c++){
N = eval(tempObj[c]);
}
totTime = (new Date().getTime( ) - stTime)
frm["Dur"+p].value = totTime;
frm["Avr"+p].value = (totTime/lim);
frm["Res"+p].value = N;
}else{
frm["Dur"+p].value = 'X';
frm["Avr"+p].value = 'X';
frm["Res"+p].value = 'X';
}
act(p+1);
}
function FunctionObject( p){
if(frm['Cb'+p].checked){
var lim = +frm['loopLimit'].value;
var N;
var totTime,stTime = new Date().getTime( );
for(var c = 0;c < lim;c++){
N = new Function('retur n ('+tempObj[c]+');')();
}
totTime = (new Date().getTime( ) - stTime)
frm["Dur"+p].value = totTime;
frm["Avr"+p].value = (totTime/lim);
frm["Res"+p].value = N;
}else{
frm["Dur"+p].value = 'X';
frm["Avr"+p].value = 'X';
frm["Res"+p].value = 'X';
}
act(p+1);
}
function splitNparseFloa t(p){
if(frm['Cb'+p].checked){
var lim = +frm['loopLimit'].value;
var N,temp;
var totTime,stTime = new Date().getTime( );
for(var c = 0;c < lim;c++){
temp = tempObj[c].split('/')
N = parseFloat(temp[0])/parseFloat(temp[1]);
}
totTime = (new Date().getTime( ) - stTime)
frm["Dur"+p].value = totTime;
frm["Avr"+p].value = (totTime/lim);
frm["Res"+p].value = N;
}else{
frm["Dur"+p].value = 'X';
frm["Avr"+p].value = 'X';
frm["Res"+p].value = 'X';
}
act(p+1);
}
function splitNunaryPlus (p){
if(frm['Cb'+p].checked){
var lim = +frm['loopLimit'].value;
var N,temp;
var totTime,stTime = new Date().getTime( );
for(var c = 0;c < lim;c++){
temp = tempObj[c].split('/')
N = (+temp[0])/(+temp[1]);
}
totTime = (new Date().getTime( ) - stTime)
frm["Dur"+p].value = totTime;
frm["Avr"+p].value = (totTime/lim);
frm["Res"+p].value = N;
}else{
frm["Dur"+p].value = 'X';
frm["Avr"+p].value = 'X';
frm["Res"+p].value = 'X';
}
act(p+1);
}
function splitNdivide(p) {
if(frm['Cb'+p].checked){
var lim = +frm['loopLimit'].value;
var N,temp;
var totTime,stTime = new Date().getTime( );
for(var c = 0;c < lim;c++){
temp = tempObj[c].split('/')
N = temp[0]/temp[1];
}
totTime = (new Date().getTime( ) - stTime)
frm["Dur"+p].value = totTime;
frm["Avr"+p].value = (totTime/lim);
frm["Res"+p].value = N;
}else{
frm["Dur"+p].value = 'X';
frm["Avr"+p].value = 'X';
frm["Res"+p].value = 'X';
}
act(p+1);
}
</script>
</head>
<body>
<p>
<form name="f" action="#">
Loop Length = <input type="text" value="50000"
name="loopLimit "> Some browsers will put up an &quot;A script on
this page is making the browser run slowly&quot; dialog. If this
happens the results for the test will be invalid and a shorter loop
will be needed. However, JavaScript Date objects do not tend to be
accurate to less than 10 milliseconds so duration results that are
not different by at least 20 milliseconds (and preferably 100+) are
not necessarily meaningful and a longer loop may be needed to acquire
useful results.<br><br >
<input type="button" value="Test" name="bt" onclick="doTest s();">
Repeat tests to reduce/expose the influence of background tasks.
<br><br>
Empty Loop Duration (milliseconds) = <input type="text" value="X"
name="Dur0"><br >
Empty Loop Average (milliseconds) = <input type="text" value="X"
name="Avr0" size="22"><br>< br>
Test <code>N = eval(tempObj[i]);</code> ? <input type="checkbox"
name="Cb1" checked><br>
<code>N = eval(tempObj[i]);</code> Duration (milliseconds) =
<input type="text" value="X" name="Dur1"><br >
<code>N = eval(tempObj[i]);</code> Average (milliseconds) =
<input type="text" value="X" name="Avr1" size="22"><br>
(result = <input type="text" value="X" name="Res1" size="22">)<br> <br>
Test <code>N = new Function('retur n ('+tempObj[i]+');')();</code> ?
<input type="checkbox" name="Cb2"><br>
<code>N = new Function('retur n ('+tempObj[i]+');')();</code>
Duration (milliseconds) = <input type="text" value="X"
name="Dur2"><br >
<code>N = new Function('retur n ('+tempObj[i]+');')();</code>
Average (milliseconds) = <input type="text" value="X"
name="Avr2" size="22"><br>
(result = <input type="text" value="X" name="Res2" size="22">)<br> <br>
Test <code>N = parseFloat(myNu mber[0])/parseFloat(myNu mber[1]);</code>
? <input type="checkbox" name="Cb3" checked><br>
<code>N = parseFloat(myNu mber[0])/parseFloat(myNu mber[1]);</code>
Duration (milliseconds) = <input type="text" value="X"
name="Dur3"><br >
<code>N = parseFloat(myNu mber[0])/parseFloat(myNu mber[1]);</code>
Average (milliseconds) = <input type="text" value="X"
name="Avr3" size="22"><br>
(result = <input type="text" value="X" name="Res3" size="22">)<br> <br>
Test <code>N = (+myNumber[0])/(+myNumber[1]);</code> ? <input
type="checkbox" name="Cb4" checked><br>
<code>N = (+myNumber[0])/(+myNumber[1]);</code>
Duration (milliseconds) = <input type="text" value="X"
name="Dur4"><br >
<code>N = (+myNumber[0])/(+myNumber[1]);</code>
Average (milliseconds) = <input type="text" value="X"
name="Avr4" size="22"><br>
(result = <input type="text" value="X" name="Res4" size="22">)<br> <br>
Test <code>N = myNumber[0]/myNumber[1];</code> ?
<input type="checkbox" name="Cb5" checked><br>
<code>N = myNumber[0]/myNumber[1];</code>
Duration (milliseconds) = <input type="text" value="X"
name="Dur5"><br >
<code>N = myNumber[0]/myNumber[1];</code>
Average (milliseconds) = <input type="text" value="X"
name="Avr5" size="22"><br>
(result = <input type="text" value="X" name="Res5" size="22">)<br> <br>
<input type="button" value="Test" name="bt" onclick="doTest s();">
Repeat tests to reduce/expose the influence of background tasks.
<br><br>
Results: (duration of test - duration of empty loop) / loop length<br>
<code>N = eval(tempObj[i]);</code> Average (milliseconds) =
<input type="text" value="X" name="CAvr1" size="22"><br>
<code>N = new Function('retur n ('+tempObj[i]+');')();</code>
Average (milliseconds) = <input type="text" value="X"
name="CAvr2" size="22"><br>
<code>N = parseFloat(myNu mber[0])/parseFloat(myNu mber[1]);</code>
Average (milliseconds) = <input type="text" value="X"
name="CAvr3" size="22"><br>
<code>N = (+myNumber[0])/(+myNumber[1]);</code> Average (milliseconds)
= <input type="text" value="X" name="CAvr4" size="22"><br>
<code>N = myNumber[0]/myNumber[1];</code> Average (milliseconds) =
<input type="text" value="X" name="CAvr5" size="22"><br>< br>
Differences (<code>((Math.r ound(Math.rando m()))||-1)</code> = 100%)
<br><code>N = eval(tempObj[i]);</code> = <input type="text" value="X"
name="PAvr1" size="22">%<br>
<code>N = new Function('retur n ('+tempObj[i]+');')();</code> =
<input type="text" value="X" name="PAvr2" size="22">%<br>
<code>N = parseFloat(myNu mber[0])/parseFloat(myNu mber[1]);</code> =
<input type="text" value="X" name="PAvr3" size="22">%<br>
<code>N = (+myNumber[0])/(+myNumber[1]);</code> = <input type="text"
value="X" name="PAvr4" size="22">%<br>
<code>N = myNumber[0]/myNumber[1];</code> = <input type="text"
value="X" name="PAvr5" size="22">%<br>
</form>
</p>
</body>
</html>

Richard.
Jul 20 '05 #7
JRS: In article <20************ *************** @mb-m21.aol.com>, seen in
news:comp.lang. javascript, HikksNotAtHome <hi************ @aol.com>
posted at Sun, 17 Aug 2003 17:55:11 :-
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
}

<select onchange="check It(this.value)" >
<option value="0">0</option>
<option value="1/16">1/16</option>
<option value="1/8">1/8</option>
............ ..
<option value="7/8">7/8</option>
<option value="15/16">15/16</option>
</select>

Don't be afraid of eval. In this case you need to evaluate a string
chosen at run time, for which eval is appropriate. Pre-conversion of
value to a numeric literal form gives long numbers or inaccuracy, if the
denominator is not a power of two.

Speed does NOT matter, since the evaluation only occurs after a manual
operation. Here, efficiency is code shortness.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - FAQqish topics, acronyms & links;
some Astro stuff via astro.htm, gravity0.htm; quotes.htm; pascal.htm; &c, &c.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Jul 20 '05 #8
In article <20************ *************** @mb-m02.aol.com>,
hi************@ aol.com (HikksNotAtHome ) writes:
But I wasn't avoiding eval for the sake of avoiding it. When I first tried
it, I actually expected it to be slower, and got to looking at it, and thinkingabout what it was actually doing, and then started testing it. Saw where eval
was faster, so I wanted other opinions on it. There may even be a flaw in my
test itself?


Many thanks to everyone who replied.

For now, I am going to go ahead and use the split/divide approach, not because
of speed (I dont see how it can make *any* perceptible difference to the user,
not when you start talking in the decimal range of ms to execute it once,
either way), for no other reason than my own sanity with regards to eval. I
have spent the better part of 6 months fighting the use of eval. It took me 2
months to show them that I could get at any form element, no matter how
bastardized they made it, without eval, so instead of going back and saying
"Hey, in IE, eval actually does it faster", I will just use the split/divide
method. Then, if its ever converted (the intranet), to a non-IE environment, I
will have the fastest of the 2 already in place.

Again, thanks to all. Now, I can get to hacking/whacking at Jims crypto page.
--
Randy
All code posted is dependent upon the viewing browser
supporting the methods called, and Javascript being enabled.
Jul 20 '05 #9
HikksNotAtHome wrote:
In article <20************ *************** @mb-m02.aol.com>,
hi************@ aol.com (HikksNotAtHome ) writes:
But I wasn't avoiding eval for the sake of avoiding it. When I first tried
it, I actually expected it to be slower, and got to looking at it, and

thinking
about what it was actually doing, and then started testing it. Saw where eval
was faster, so I wanted other opinions on it. There may even be a flaw in my
test itself?


Many thanks to everyone who replied.

For now, I am going to go ahead and use the split/divide approach, not because
of speed (I dont see how it can make *any* perceptible difference to the user,
not when you start talking in the decimal range of ms to execute it once,
either way), for no other reason than my own sanity with regards to eval. I
have spent the better part of 6 months fighting the use of eval. It took me 2
months to show them that I could get at any form element, no matter how
bastardized they made it, without eval, so instead of going back and saying
"Hey, in IE, eval actually does it faster", I will just use the split/divide
method. Then, if its ever converted (the intranet), to a non-IE environment, I
will have the fastest of the 2 already in place.

Again, thanks to all. Now, I can get to hacking/whacking at Jims crypto page.
--
Randy


May I also suggest that instead of:

<select onchange="func( this.value);">

you use:

<select onchange="func( this.options[this.selectedIn dex].value);">
:)

--
| Grant Wagner <gw*****@agrico reunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #10

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

Similar topics

8
2273
by: neblackcat | last post by:
Would anyone like to comment on the following idea? I was just going to offer it as a new PEP until it was suggested that I post it here for comment & consideration against PEP 308. I'm far from being a "language internist" (on Python or anything else) so go easy on me if this is stupid - it just seemed quite elegant to me as a relative newbie in town :-) I also havent got a clue whether this would be easy or even possible
3
6302
by: McKirahan | last post by:
I said I wouldn't use "eval()" anymore but I need help to do it. Below is some stripped-down code (4 lines; watch for word-wrap) extracted from USGA.COM that preloads images: main_nav_home_F1 = new Image(153,21); main_nav_home_F1.src = "images/main_nav_home.gif"; main_nav_home_F2 = new Image(153,21); main_nav_home_F2.src = "images/main_nav_home_F2.gif"; main_nav_about_F1 = new Image(153,21); main_nav_about_F1.src =
7
4100
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 the script and special attention was thrown at the fact the script used eval alot. I don't use eval alot in my scripts - but I do use it - and since I always out to learn more / improve my javascript skills, I'm curious why something I thought...
24
4490
by: Wim Roffal | last post by:
Is there a possibility to do a string replace in javascript without regular experessions. It feels like using a hammer to crash an egg. Wim
7
2266
by: steveneill | last post by:
Is this an alternative to eval(). Admittidly, I have done *very* little testing (ran it a few times in Firefox), but it seemed to work suprisingly well with simple expressions such as "alert('hello')" function _eval(s) { var h = document.getElementsByTagName("HEAD"); var o = document.createElement("SCRIPT"); o.text = s; h.appendChild(o);
3
1181
by: BUX | last post by:
I have to get public variable value using variable name. Evals("myPublicVariable") do nor work How can I do? thank you
3
2940
by: Vik Rubenfeld | last post by:
I'm working on integrating the a javascript wysiwyg editor (Xinha) with my blog software (ExpressionEngine, aka EE). EE has extensions now so it's easy to get the Xinha header code into the head section of the EE web page. But Xinha likes to use an onload command to launch: window.onload = xinha_init; ....and EE is already using the onload command in the body tag of the web
7
1180
by: Cramer | last post by:
In addition to Web.config, I have a few configuration values that I store in a sql server database. I would like to read them from the database only once per Application.Start (there is no need to read the values per session, as the values are used throughout the entire application and are needed by many pages). Just wondering if Application state would be the best place to store these values. Are there better alternatives for my...
4
2116
by: spamme | last post by:
Hi, As you can see from the following code, I am trying to manipulate a large number of layers. I have read many times in the past how the "Eval" function should be used very sparingly as it can make code run slowly. The following works fine on my PC, however I do not know what will happen on other platforms, so is there an alternative to "Eval" in this instance. for(var i=1;i<505;i++){
0
8162
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8105
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,...
0
8605
Oralloy
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...
1
8246
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6076
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 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...
0
4109
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2550
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
1
1695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1413
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.