views:

289

answers:

1

hi,

how to deal with value attribute of any element (hidden input in my case)

i have tried with two styles

alert($("#projectManager").attr("value"));

and 

alert($("#projectManager").val());

but it returns 'undefined'.

any help?

+3  A: 

Make sure you specify id="projectManager" on the input field. a 'name' attribute is not enough for this selector. And .val() is the way to go to get a field value.

Traveling Tech Guy
thank you, i just missed it i have given name instead of id.BTW how did u know i have used name? :-)
sangram
Because that's the required attribute for a form element - otherwise you won't get it on the server when submitted :)
Traveling Tech Guy