I have created a UI page in jsp. I have a combobox in which I need the All option to be selected as default during the first load. It is the second one in the combo and the first is "MY favourites". However my issue is that I cannot see the "My favourites " in the combo. my code is as follows:
function setCategory()
{
window.external.getParamFromUsrProfile("templatelistcategory", strCat, false);
$.ajax({
url: 'getTempPrPermissions.jsp',
data:"TrUserId="+TrUserId,
type: 'POST',
success: function(data)
{
var strCategory = "< option value='-1'>My Favorites</option> <option value='0'>All</option>";
data = parseXml(data);
$(data).find("item").each(function()
{
strCategory +="<option ";
if(strCat == $(this).find("CategoryId").text())
{
strCategory += " selected=true ";
}
strCategory += "value='"+$(this).find("CategoryId").text()+"'>"+$(this).find("catName").text()+"</option>" ;
});
$("#selectCategory").html(strCategory);
}
});
}
The -1 value for "my favourites" option cannot be changed as that is what is expected by the function which uses these values.Please help.
Thanks, Anita
I made the following change and it worked. I am still not sure what was wrong with my earlier code. If only someone could explain.
success: function(data)
{
var strCategory = "<option value='-1'>My Favorites</option>";
strCategory += "<option value='0'>All</option>";
data = parseXml(data);
$(data).find("item").each(function()
{
strCategory +="<option ";
if(strCat == $(this).find("CategoryId").text())
{
strCategory += " selected=true ";
}
strCategory += "value='"+$(this).find("CategoryId").text()+"'>"+$(this).find("catName").text()+"</option>" ;
});
$("#selectCategory").html(strCategory);
}