Hi,
I have this:
function getRequestDescriptions(requestCategory) {$.ajax({ url: 'phpservices/getRequestDescriptions.asp, dataType: 'json', data: { requestCategory: requestCategory } }) .done(function(descriptionInfo) { // get number of items in array given by asp var Desc_count = descriptionInfo.length; // start an array to hold re-arranged buildings array var newDescriptionInfo = []; // loop request descriptions for (var i = 0; i < Desc_count; i += 1) { // append an <option> tag to your <select>$('#description').append('<option value="' + descriptionInfo[i].RequestDescriptionDisplay + '">' + descriptionInfo[i].RequestDescriptionDisplay + '</option>'); // set the key value to SiteContactDisplay so that it is easily referenced later newDescriptionInfo['' + descriptionInfo[i].RequestDescriptionDisplay + ''] = descriptionInfo[i]; } // Listen for the value of the <select> to change$('#description').on('change', function () { // Hidden inputs must already be available on the form before this Javascript is ever used // Set the value of the hidden fields based on the <select>'s ID choosing the corret array element$('input[name="RequestID"]').val(newDescriptionInfo[''+$(this).val()+''].RequestID); }); }); }
Then this:
<input name="RequestID" id="RequestID" type="text" width="300" value="" class="changeable" /><br><select name="description" id="description" style="width:600px;font-size:10pt;" class="changeable" data-summary="summSubCategory">
Our intention is that if a user selects a value from te description dropdownlist, the value of the associated requestId will be populated in hidden form.
However, whe I tried to test this, it displays a bunch of nulls along with real values.
More, it doesn't matter what option I select from the description dropdownlist, I get same values.
Can you please tell me what I am doing wrong?
I do have some that actually work.
Not sure why this is not working.
Thanks in advance