Harsha vardhan
Harsha vardhan

Reputation: 23

IE7 getting null or object value in form

I have a form with hidden fields with name.In javascript I am getting the form hidden value using following expression

document.getElementById('form-name').hidden-input-name.value.

In all browsers it is working fine except IE7.In IE7,I am getting value as null or not an object for the above expression. Can anyone help me please.Thanks

Upvotes: 2

Views: 786

Answers (3)

Parv Sharma
Parv Sharma

Reputation: 12705

Do you have any other element with attribute name = "form-name" because older versions of IE didn't distinguish b/w id="" and name=""

Upvotes: 1

Tobias Krogh
Tobias Krogh

Reputation: 3932

untested but how about trying:

document.getElementById('form-name')["hidden-input-name"].value

Upvotes: 0

Shadow Wizard
Shadow Wizard

Reputation: 66388

The element name is not a valid JavaScript identifier, so you must use such syntax instead:

var value = document.getElementById('form-name').elements("hidden-input-name").value;

Upvotes: 0

Related Questions