/    Sign up×
Community /Pin to ProfileBookmark

What does this error means????

HI

var cId=document.form.cn[document.form.cn.selectedIndex].value;

For this line of code
I am getting the following error
document.form.cn[..].value’ is not an object.

What are the possible reasons for the above error.
ShaRa

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@JustinJun 17.2003 — it usualy means that you didn't define the form name the same or something. it says that it cant find that form on the page
Copy linkTweet thisAlerts:
@shanuraguauthorJun 17.2003 — Because

I have a form with a name 'form' and a list box by name 'cn'

Both names mentioned the code are existing!!.

Any other reason??

ShaRa
Copy linkTweet thisAlerts:
@JustinJun 17.2003 — this is a long shot but it mite work depending on the browser try adding

window.document.form.cm ? ?
Copy linkTweet thisAlerts:
@shanuraguauthorJun 17.2003 — No it is not working!!!? :mad:
Copy linkTweet thisAlerts:
@gsbJun 17.2003 — Without code it is often hard to figure.

Are you using the line of code BEFORE the form is defined in the document?
Copy linkTweet thisAlerts:
@Khalid_AliJun 17.2003 — [i]Originally posted by shanuragu [/i]

[B]Because

I have a form with a name 'form' and a list box by name 'cn'



ShaRa [/B]
[/QUOTE]


form is an element name and if you give a form name value form..don't you think you are trying to confuse the javascript engine???

Never assign name attribute value which is the name of that element.

Change the form elements name to "form1" or something else.And then if th eselect box has name="cn" then you are business
×

Success!

Help @shanuragu 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.20,
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,
)...