You need to sign in to do that
Don't have an account?
Robert Wynter
ampscript jquery call function for dropdown list
I can add the list with a for loop but I'd like to call a function and have that function append the items to the list. I have both on my code Just can't seem to figure out the call function option.
<table> <tr><th>Test 8</th></tr> <tr> <td> %%[/* Modify to view AMPScript <div style="display:none"> */ var @DEProgramOfInterest, @lookupValue, @rowCount,@rows,@numRowsToReturn set @lookupValue = "1234" /* ID for all records */ /*Lookup("DataExtensionName"= the name of the Cloud Page Extention, "ReturnColumn" = the column NAME where the record you wish to retrive is located "LookupColumn" = the column you will use to match the value, @lookupValue = the referenced value you wish the lookuoColumn to find)*/ set @multiRows = LookupRows("Program_of_Interest","ID",@lookupValue) if @rowCount > 0 then /*Loop through rows and set variable to records while passing through loop*/ for @i = 1 to RowCount(@multiRows) do var @Program_of_Interest Set @row = Row(@multiRows,@i) set @Program_of_Interest = field(@row,"Program of Interest") /*Start of dropdown when count = 1*/ if @i == 1 then outputline(concat("<select ><option value="">None</option>")) outputline(concat("<option value="">None</option>")) endif /*</div>*/ ]%% /*add values to dropdown*/ <option value="">%%=v(@Program_of_Interest)=%%</option> %%[ /*end of dropdown*/ if @i == @rowcount then outputline(concat(" </select>")) endif ]%% <!-- this is my function call of fillDataList --> <script type="text/javascript"> var newOption = $(fillDataList(%%=v(@Program_of_Interest)=%%)) $('#test').append(newOption) </script> %%[ next @i ]%% </td> %%[ else ]%% No rows found %%[ endif ]%% </tr> <tr> <td> <select class="test"> </select> </td> </tr> <tr> <td> </td> </tr> </table> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script> var fillDataList = function( options ) { var items = '' $.each( options, function ( index, option ) { items += '<option value="' + option + '">' items += option items += '</option>' }) return items } </script>
Robert Wynter
I striped it down to just the select tags, the function and a static function call. If I can get this working then I can re insert the ampscript variables