/    Sign up×
Community /Pin to ProfileBookmark

Javascript error – please help

I have the following code:

var itemids = new Array(“id65|a|Any Football Shirt|Any football shirt of your choice|3”, “id80|a|Other sports shirts|Other sports shirts if available, please raise a support ticket with your choice.|3”, “id66|a|Personalised Football Shirt|Any football shirt of your choice with your name and number on the back.|4 id65|a|Any Football Shirt|Any football shirt of your choice|3”, “id80|a|Other sports shirts|Other sports shirts if available, please raise a support ticket with your choice.|3”, “id66|a|Personalised Football Shirt|Any football shirt of your choice with your name and number on the back.|4”)

function changeitem(itemid) {
for (i=0; i < itemids.length; i++) {
var separated = itemids[i].split(“|”);
document.getElementById(separated[0]).className = “”;
if(separated[0] == itemid) { var changeme = i;
}
}

var separated = itemids[changeme].split(“|”);
document.getElementById(itemid).className = “selected”;
document.getElementById(“image”).src = “images/” + separated[1];
document.getElementById(“name”).innerHTML = separated[2];
document.getElementById(“description”).innerHTML = separated[3];
document.getElementById(“iteminfo”).innerHTML = (separated[2] + ” – ” + separated[4] + ” referrals”);
document.getElementById(“itemfield”).value = separated[0];
scroll(0, 0);

}

and it keeps telling me itemids is not defined, but the code works fine in FF just not in IE. I have no clue what i’m doing wrong

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@moviedromeauthorMar 16.2008 — sorry, should have mentioned that above that i have

var itemids = new Array("id10|a|Apollo X-Rated XC.05 14/26 Mens Bike|Hi-tensile gusseted jumps style steel frame, Dirt jump style bike, 18 speed Shimano gears with SRAM gripshifter, Powerful steel V type brakes, and 2.3 dirt jump tyres with aluminium rims.|5", "id8|a|Shockwave SUS 750 Mountain Bike Unisex|Strong Hi-tensile steel frame, Front and rear suspension, Smooth off road ride, Front and rear disc brakes.|6", "id9|a|Raleigh Freeride 21 Mens Bike|Suntour M300 front suspension fork, 18 speed Shimano gears with Revoshifters, Tektro V-brakes and Accedo aluminium rims with lightweight aluminium hubs|9 id10|a|Apollo X-Rated XC.05 14/26 Mens Bike|Hi-tensile gusseted jumps style steel frame, Dirt jump style bike, 18 speed Shimano gears with SRAM gripshifter, Powerful steel V type brakes, and 2.3 dirt jump tyres with aluminium rims.|5", "id8|a|Shockwave SUS 750 Mountain Bike Unisex|Strong Hi-tensile steel frame, Front and rear suspension, Smooth off road ride, Front and rear disc brakes.|6", "id9|a|Raleigh Freeride 21 Mens Bike|Suntour M300 front suspension fork, 18 speed Shimano gears with Revoshifters, Tektro V-brakes and Accedo aluminium rims with lightweight aluminium hubs|9")
Copy linkTweet thisAlerts:
@mrhooMar 16.2008 — I don't see where [B]itemid [/B]is defined in-

document.getElementById([B]itemid[/B]).className = "selected";

Chances are you just don't have warnings set to alert on firefox-

not setting a class won't break the code, but IE doesn't know that.

If that is not the problem, it could be the way you are trying to manipulate named fields with innerHTML-

IE is strict about scripting changes to any form field with a name attribute.
×

Success!

Help @moviedrome 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...