I have one line in my could that's giving me a 500 internal err and it's my append to the dropdown list. I've tried $('#test').append(fillDataList(obj)); and jQuery('#test').append(fillDataList(obj));


<script runat="server">   
  Test Dropbox 8
<select id="test"></select>


  <script runat="server"> 
    var fillDataList = function( options )
      var items = '';
        $.each( options, function ( index, option ) {
            items += '<option value="' + option + '">'
            items += option
            items += '</option>'
            return items

var obj = { one: 'hey 1', two: 'hey 2', three: 'hey 3', four: 'hey 4', five: 'hey 5'};


  • The SFMC server-side JavaScript runs before the page loads, so keep that in mind. Looks like you're mixing client-side jQuery and SSJS. That won't work. – Adam Spriggs Dec 30 '16 at 4:36
  • Thanks for the clarification. Would you be able to point me in the right direction to getting this to work as ssjs. i haven't been able to find any examples that helps me understand. I'm a visual person I need to see some form of example to understand – Robert Wynter Dec 30 '16 at 13:53

Here's how I've accomplished something similar in SSJS. The idea is that you build the Select HTML in a SSJS block and output it in the body of the page.

<script runat="server">


  var MONTHNAMES = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
  var monthSelect = "<select>";
  monthSelect += "<option value=''>Select Month</option>";

  for (var i = 0; i < MONTHNAMES.length; i++) {
     monthSelect += "<option value='"+MONTHNAMES[i]+"'>" +MONTHNAMES[i]+ "</option>";

  monthSelect += "</select>";


Month: <ctrl:eval>monthSelect</ctrl:eval>



month select

  • This is perfect thank you so much. Can you please explain <ctrl:eval> I came across this in the MC docs but didn't quit understand it – Robert Wynter Dec 30 '16 at 17:21
  • Most of the good SSJS stuff is outlined on the SSJS Syntax Guide wiki page. – Adam Spriggs Dec 30 '16 at 20:35
  • Also, this answer has a good overview of the resources: salesforce.stackexchange.com/a/130337/5202 – Adam Spriggs Dec 30 '16 at 20:38
  • What if I want to replace the var MONTHNAME to equal an html page content. I tried %%[ set @JSON = HttpGET("insert URL here") ]%% but when printed out come out all garbaly goop. instead of the content on that json page which is [ " Child and Youth Worker ", " Energy Systems Engineering Technology ", " Digital Photography ",]; – – Robert Wynter Jan 1 '17 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.