I know I am missing something simple but I have some variables that equal a path and file name:
overview_path = “data/overview/”;
console_path = “data/console/”;
overview_page_list = new Array();
console_page_list = new Array();
console_page_list[0] = “a1-purpose.html”;
console_page_list[1] = “a2-components.html”;
I have a function trying to dynamically put them together.
function getGroupPages(whichGroup) {
if (whichGroup!=null)
{
groupInUse = whichGroup;
}
var path = groupInUse + “_path”;
var list = groupInUse + “
top.Main.location = path + list+”[0]”;
}
If I call the function with the following parameter
getGroupPages(“console”);
I want the file data/overview/a1-purpose.html to goto the Main frame. But when I use a debugging alert function to view path+list+”[0]” I get console_pathconsole_page_list[0] instead of what of the inners of data/overview/a1-purpose.html Can anyone help?
top.Main.location = window[path] + window[list][0];
var overview_path = "data/overview/";
var console_path = "data/console/";
overview_page_list = new Array();
console_page_list = new Array();
console_page_list[0] = "a1-purpose.html";
console_page_list[1] = "a2-components.html";
function getGroupPages(whichGroup,n) {
groupInUse = whichGroup;
path = eval(groupInUse+"_path");
list = eval(groupInUse+"_page_list"+"[n]");
full = path+list;
alert(full);
//top.Main.location = full;
}
[i]Originally posted by WestPac [/i]This is the rudest thing I've ever heard. The peple you are referring to are the most respecte dof members, who vounteer here to help make the Web more accessible.
[B] If upon meeting someone for the first time, he introduced himself as Supreme Master of the Web, wouldn't you just giggle? If not, then there are two fools, you, and the person who fancies himself to be supreme.
There are several of them running around loose here. You can easily spot them, because of such goofy monikers, or juvenile 'signatures' quoting some asinine 'professor' or repeating some arcane prose. [/b][/quote]
[i]Originally posted by WestPac [/i]This is completely incorrect. Members here want to help you learn (see below)
[B] More often then not, they pose a question to your question, or they attempt to persuade you from doing what you want to do, in the manner that you want to do it. Curiously though, on the rare occasions that they actually offer code, it's a mere snippet, containing such garbage like "foo." Never do they offer a complete working example which directs itself to solving your problem. [/b][/quote]
[i]Originally posted by WestPac [/i]Please calm down. The supreme master of the web is an auto-title for his post count, provided he doesn't change it. And moreover, he is absolutely correct, and you are absolutely wrong.
[B] I regard them the same way I would a toddler stomping his feet, "look at me!, look at me!, look at me!"
Right, that's helpful. Tell me to find another way. Great. Tell me to not use something that works. Gee, thanks. Go ahead. Stomp your feet. [/B][/QUOTE]
path = window[groupInUse+"_path"];
list = window[groupInUse+"_page_list"][n];
That works because the following is true:var str = "My String";
alert(str == window['str']); // alerts true
You really should work on the way you present yourself. Be thankful you have received the help you have gotten.[i]Originally posted by WestPac [/i]
[B]Killiank:
If upon meeting someone for the first time, he introduced himself as Supreme Master of the Web, wouldn't you just giggle? If not, then there are two fools, you, and the person who fancies himself to be supreme.
There are several of them running around loose here. You can easily spot them, because of such goofy monikers, or juvenile 'signatures' quoting some asinine 'professor' or repeating some arcane prose.
More often then not, they pose a question to your question, or they attempt to persuade you from doing what you want to do, in the manner that you want to do it. Curiously though, on the rare occasions that they actually offer code, it's a mere snippet, containing such garbage like "foo." Never do they offer a complete working example which directs itself to solving your problem.
I regard them the same way I would a toddler stomping his feet, "look at me!, look at me!, look at me!"
Right, that's helpful. Tell me to find another way. Great. Tell me to not use something that works. Gee, thanks. Go ahead. Stomp your feet. [/B][/QUOTE]
[i]Originally posted by DUNSEL [/i]What do you think you are doing DUNSEL. You are not acting at all "supreme". hehe, absolutely true what you said.
[B]Perhaps if you waited until you amassed more than 9 posts, and were somwhat familiar with the board's function, before lashing out in ignorance at fellow members, you'd be aware that all designations such as webmaster, supreme master of the web, etc. are BOARD attached designations associated with post totals. They have NOTHING to do with member choices. They are NOT member selected. Now you may attempt to extricate your foot from your mouth. [/B][/QUOTE]
[i]Originally posted by DUNSEL [/i]I've seen it a bunch ... but normally in the fashion of "I don't want you modifying my code you <insert bad language here>".
[B]Sorry I just never saw anyone respond with such unprovoked blatant belligerence before, on here at least. [/B][/QUOTE]
You don't want to use eval() if at all possible[/QUOTE]
I've done some benchmarking on using eval('document.images.'+sName) versus document.images[sName]. I've found eval to take about 12 times the time the associative array takes in op7 (op6 had a radically different scripting engine where everything took much more time, but the comparison made eval just 1.5 times slower), 2.5 times in moz, 5 times in ie, 7.5 in nn4.
Eval also is a really hungry memory eater while executing.
Depending on what you use eval for, you can often replace it with more efficient code.
Associative arrays are the most usual replacement.)
[/QUOTE]
[i]Originally posted by Mr J [/i]That is what toddlers do, and we three know like the best of 'em.
[B]I wasn't going to reply to this but I feel that I must at least thank [B]Steelersfan88[/B] and [B]Dunsel[/B] for jumping to my defense.[/B][/QUOTE]
<html>
<head>
<script type="text/javascript">
<!--
function testTimes() {
var numIterations = 100000;
var outputHTML = '';
<i> </i> var startTime = new Date().getTime();
<i> </i> for (var loop=0; loop<numIterations; loop++) var testValue = document.forms[0].elements['test1'].value;
<i> </i> var endTime = new Date().getTime();
<i> </i> outputHTML += 'Time taken without eval for ' + numIterations + ' iterations: ' + ((endTime-startTime)/1000) + ' seconds';
<i> </i> outputHTML += '<br />';
<i> </i> var startTime = new Date().getTime();
<i> </i> for (var loop=0; loop<numIterations; loop++) var testValue = eval('document.forms[0].elements[\'test' + 1 + '\'].value');
<i> </i> var endTime = new Date().getTime();
<i> </i> outputHTML += 'Time taken with eval for ' + numIterations + ' iterations: ' + ((endTime-startTime)/1000) + ' seconds';
<i> </i> document.getElementsByTagName('body')[0].innerHTML = outputHTML;
<i> </i> }
<i> </i>//-->
<i> </i></script>
</head>
<body onload="testTimes();">
<form>
<input type="hidden" name="test1" value="Test" />
</form>
</body>
</html>
[code=php]<script type="text/javascript">
<!--
directory="folder/"
function test(){
var v1=document.f1.s1.options[document.f1.s1.selectedIndex].value;
var v2=document.f1.s2.options[document.f1.s2.selectedIndex].value;
var v3=document.f1.s3.options[document.f1.s3.selectedIndex].value;
str=directory+v1+v2+v3+".html"
alert(str)
}
//-->
</script>
<form name="f1" onsubmit="return test()">
<select name="s1">
<option value="PA">PA
<option value="Two">Two
<option value="Fee">Fee
</select>
<select name="s2">
<option value="Bucks">Bucks
<option value="Pints">Pints
<option value="Fie">Fie
</select>
<select name="s3">
<option value="Dentists">Dentists
<option value="Please">Please
<option value="Foe">Foe
</select>
<input type="submit" value="Test">
</form>[/code]
0.1.9 — BETA 5.19