I have this fields
<input type="hidden" id="uidhcdm" name="uidhcdm" value="0">
<input type="hidden" id="uidhcdm" name="uidhcdm" value="0">
and i am using a function called change val
function changeval(x,val)
{
$('#'+x).val(val);
}
but when i run the function it only affects the first hidden fields value but not the seconds!
Please help me !!
You have to recognize that the attribute “id” of a tag has to be unique. You can define more elements with the same value for “id” but every DOM access will only retrieve the first one, since, by definition, only one elements is allowed to have one specific id.
Other words: having the same id for more than one element is malformed code.