0

i have a picklist its name is new_tariff and i want to add values to picklist onload using js or jquery.How can i do it ?

Mennan
  • 4,451
  • 13
  • 54
  • 86

1 Answers1

0
document.onLoad(function(){
$(#new_tariff).append(" VALUES TO BE APPENDED ");
});

This assumes new_tariff is set to id="new_tariff". Replace the # with a . if you're using a class. These are much simpler than a name: $.prop("name", "new_tariff") (http://api.jquery.com/prop/).

FYI there is $.prepend() which does almost exactly the same thing as append, except it adds it to the beginning instead of the end.

It would probably be better to have some default value(s) that you replace onLoad in case the onLoad fails. To do this you would use $.html() to replace the default values with the ones from onLoad. (you can also store the values externally and do an $.ajax() call to $.load() them in, but this is more complicated.

Jakob Jingleheimer
  • 30,952
  • 27
  • 76
  • 126
  • You may not know, but Dynamics CRM requires the usage of its object model to achieve the requirement. There is no (supported) access to the markup. – ccellar Sep 13 '11 at 19:57
  • Ohhh, I did not. I was thinking CRM=Change Request Management. Sorry if this doesn't apply (I'll leave this up in case it does) – Jakob Jingleheimer Sep 13 '11 at 20:04