简体   繁体   中英

why getElementsByName is giving undefined value in javascript?

Hi I have a dropdownlist as a column within a gridview. gridview has multiple rows. In Page Source of this Page I see same Id for all the drodownlists of each row, but name is differenet. So I want to get the selected value of a dropdownlist in any nth row. So I'm trying to do the same by getElementsByName. But its giving undefind value. Why its giving undefined value and how to achieve the desired results

var DropDown= document.getElementsByName('grvRewardRulesDetails$ctl03$StartHourDropDown');

Try

document.getElementByID('<%= StartHourDropDown.ClientID %>')

Your DropDownList(DDL) is inside a GridView. Then you must try some other things. Try calling the Javascript on the onchange event of DDL

This link should help http://forums.asp.net/t/1550471.aspx

Solved Issue. getElementsByName returns array not a single value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM