/    Sign up×
Community /Pin to ProfileBookmark

Object Expected

I’ve made an script which put cookie values in form fields, it works perfectly fine in FF(no errors or warnings with firebug) But IE says gives me the error object expected.

here’s the code:

[code=php] function returnFormCookies(formName){
try {
var elem = document.getElementById(formName).elements;

}
catch (err) {
alert(‘I need the form id, not the name.’)

}

for (var i = 0; i < elem.length; i++) {

if (elem[i].type != “button”) { //Its a button?
if (elem[i].name == “”) {

var c_name = elem[i].id;
}
else {

var c_name = elem[i].name;

}
if (elem[i].type == “checkbox”) {
elem[i].checked = getCookie(c_name);
}
else {
if (elem[i].type == “radio” && elem[i].value == getCookie(c_name)) {
elem[i].checked = “checked”
}
else {
elem[i].value = getCookie(c_name)
}
}

}
else {
// Its a BUTTON
}
}

}[/code]

The function is executed onload, and the code is imported form a local .js file(not included)

Please Help

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorDec 12.2007 — Javascript DOM 0 [B]checked[/B] attribute returns and needs [B]Boolean true/false[/B] values, [I]not[/I] "checked" or whichever else, nomatter in HTML strict you write checked="checked"...
Copy linkTweet thisAlerts:
@ZelthorauthorDec 12.2007 — Even when that is done, it still generates the error
×

Success!

Help @Zelthor 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.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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