c# - Looping through a ASP.NET Listbox with Javascript not working -
i'm trying loop through asp.net listbox javascript, i'm getting null object or undefined when hits lboxright variable in loop. here's have.
function save() { var containstypea = false; var containstypeb = false; var containstype = false; var lboxright = $get('<%=lboxright.clientid %>').value; if (lboxright != null) { (var = 0; < lboxright.options.length; ++i) { if (lboxright.options[i].value == "type a") { containstypea = true; } if (lboxright.options[i].value == "type b") { containstybeb = true; } } containstype = true; } }
there's onclick event mapped when save button pressed calls function. doing right way @ listbox , tell me if has specific value in it? intention listbox contain type a
value , when loops through listbox, if finds value within list set variable true other logic. visual studio seems complain loop line, doing wrong here? using exact same loop written elsewhere , works fine, not understanding why 1 isn't working.
is there wrong have written it?
if complaining being null or undefined on loop line check see lboxright.options since check lboxright.
actually wouldn't make sense options exist since lboxright being set value of select not select.
try changing
var lboxright = $get('<%=lboxright.clientid %>').value;
to
var lboxright = $get('<%=lboxright.clientid %>');
Comments
Post a Comment