Can't add a validator to a dynamically created select list.
I'm using a jqGrd and trying to have items in the row validated when an item in the select list changes.
I figured I'd post this up here for anyone else....
-
var subJList = "<select name='subJList' id='subJList' Enabled='true' onClick='$(\"#hoursBx\").valid()' >";
for (var i = 0; i < result.SubJobs.length; i++) {
if (result.SubJobs[i].SubJobName == rowData.SubJob)
subJList += "<option selected> " + result.SubJobs[i].SubJobName + "</option>";
else
subJList += "<option>" + result.SubJobs[i].SubJobName + "</option>";
}
subJList += "</select>";
I tried many other ways to do this. I couldn't get it to work by
var subJList = createElement("select");
and then foreach ()
$("#subJList").addOption(i, jobName);
$("#subJList").selectedIndex = 3; //(Tired many different ways to set the selected index and it never worked.)
I'm open to trying different ways if anyone can suggest.
I also posted this over at StackOverFlow.
http://stackoverflow.com/questions/595205/best-way-to-create-a-dynamic-select-dropdown-list/596534#596534