Access elements after form is loaded using jquery
In the form there are 2 drop down which are created dynamically after the page loads. I have written a jquery function which will be called when 1st drop down value changes. But when I try to access the dynamically created form field value it says TypeError: e.nodeName is undefined.
- function
- flavorDefn(e) {
- var locationid = $(e).attr('id');
- var idArray = locationid.split('-');
- var id = idArray[1];
- var flavorDef="flavorDefs"+id;
- $("#"+flavorDef).prop("disabled", true);
- $.getJSON('flavorDefinitions.wss', {
- location : $(this).val(),
- ajax : 'true'
- }, function(data) {
- $("#"+flavorDef).prop("disabled", false);
- var html = '';
- var len = data.length;
- for ( var i = 0; i < len; i++) {
- html += '<option value="' + data[i].id+
- '" id="'+data[i].id+'">'
- + data[i].cpus+' CPU '+data[i].ram+' MB RAM
- '+data[i].disk+' GB DISK '+ '</option>';
- }
- html += '</option>';
- $("#"+flavorDef).html(html);
- });
- }
<select name="locationName" id="location-<%=patternBO.getId()%>" onchange="flavorDefn(this)"> <select name="flavorDefs" id="flavorDefs<%=patternBO.getId()%>">