/    Sign up×
Community /Pin to ProfileBookmark

weird variable error

// 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 :
[url]http://www.andrewu.co.uk/tools/request/[/url]

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@FangSep 07.2003 — if(x = "menu1") is always true, ==

Is that a document.write after the page has loaded?
Copy linkTweet thisAlerts:
@dotauthorSep 07.2003 — oops i ment ==

but that is just a check...i need to know y the rest aint working ?
Copy linkTweet thisAlerts:
@FangSep 08.2003 — [code=php]
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>")
}
[/code]
×

Success!

Help @dot spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...