Click to See Complete Forum and Search --> : weird variable error


dot
09-07-2003, 02:22 PM
// index.html

<a href="test.html?menu=menu1">menu1</a>
<a href="test.html?menu=menu1_1">menu1_1</a>

// index.html


// test.html

<html>
<head>
<title>Untitled</title>
<SCRIPT src="CSJSRequestObject.js" type=text/javascript></SCRIPT>
</head>

<body">
<SCRIPT type=text/javascript>
<!--
function player(number,name,position,height,college)
{
this.number = number
this.name = name
this.position = position
this.height = height
this.college = college
}

var menu1 = new Array(5)
menu1[0] = new player("20","Gary Payton","Guard"," 6'4","Oregon State")
var menu1_1 = new Array(2)
menu1_1[0] = new player("21","Pete Payton","Guard"," 6'4","Oregon State")
menu1_1[1] = new player("22","John Payton","Guard"," 6'4","Oregon State")
menu1[1] = new player("33","Hersey Hawkins","Guard"," 6'3","Bradley")
menu1[2] = new player("42","Vin Baker","Forward"," 6'11","Hartford")
menu1[3] = new player("11","Detlef Schrempf","Forward"," 6'10","
Washington")
menu1[4] = new player("22","Jim McIlvaine","Center"," 7'1"," Marquette")

var x = Request.QueryString("menu")

for (i = 0; i < x.length; i++)
{
document.write(x[i].number + x[i].name + x[i].height + x[i].position +
x[i].college + "<br>")
}
// -->
</script>
</body>
</html>

// test.html


y isn;t it working ?
if i do a check like :

if(x = "menu1")
{
alert("ok")
}

it shows its there
additional info about CSJSRequestObject.js can be found :
http://www.andrewu.co.uk/tools/request/

Fang
09-07-2003, 02:38 PM
if(x = "menu1") is always true, ==

Is that a document.write after the page has loaded?

dot
09-07-2003, 03:07 PM
oops i ment ==
but that is just a check...i need to know y the rest aint working :D

Fang
09-08-2003, 01:22 AM
for (i = 0; i <eval(x+'.length'); i++)
{
document.write(eval(x+'[i].number') + eval(x+'[i].name') + eval(x+'[i].height') + eval(x+'[i].position') + eval(x+'[i].college') + "<br>")
}