Advertisement
Guest User

Untitled

a guest
Apr 30th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.13 KB | None | 0 0
  1. $.ajax({
  2.     url: "http://localhost:8080/spatial/getRequestTypes",
  3.     type: "POST",
  4.     dataType: "text",
  5.     contentType: "application/json",
  6.     success: function (response) {
  7.         console.log("loaded");
  8.         let obj = $.parseJSON(response);
  9.  
  10.         let html_radioButtons = "";
  11.  
  12.         for (let i = 0; i < obj.length; i++) {
  13.             if (i === 0) {
  14.                 html_radioButtons += "<div style=\"display: inline-block\"><input class=\"with-gap\" type=\"radio\" id=\"radio0" + (i + 1) +
  15.                     "\" checked value=\"" + obj[i] + "\" name=\"group1\"/>" +
  16.                     "<label for=\"radio0" + (i + 1) + "\"><span></span>" + obj[i].toUpperCase() + "</label></div>";
  17.             } else {
  18.                 html_radioButtons += "<div style=\"display: inline-block\"><input class=\"with-gap\" type=\"radio\" id=\"radio0" + (i + 1) +
  19.                     "\" value=\"" + obj[i] + "\" name=\"group1\"/>" +
  20.                     "<label for=\"radio0" + (i + 1) + "\"><span></span>" + obj[i].toUpperCase() + "</label></div>";
  21.             }
  22.         }
  23.  
  24.         $("#requestType").html(html_radioButtons);
  25.     }
  26. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement