onchange select field распечатать все значения поля ввода на консоли

Вот как вы это делаете, с закругленными углами и закругленными тенями, не беспокоясь о путях.

//Inner view with content
[imageView.layer setBorderColor:[[UIColor lightGrayColor] CGColor]];
[imageView.layer setBorderWidth:1.0f];
[imageView.layer setCornerRadius:8.0f];
[imageView.layer setMasksToBounds:YES];

//Outer view with shadow
UIView* shadowContainer = [[UIView alloc] initWithFrame:imageView.frame];
[shadowContainer.layer setMasksToBounds:NO];
[shadowContainer.layer setShadowColor:[[UIColor blackColor] CGColor]];
[shadowContainer.layer setShadowOpacity:0.6f];
[shadowContainer.layer setShadowRadius:2.0f];
[shadowContainer.layer setShadowOffset: CGSizeMake(0.0f, 2.0f)];

[shadowContainer addSubview:imageView];

Вид с содержимым, в моем случае UIImageView, имеет радиус угла и поэтому должен маска к границам.

Мы создаем еще один одинаковый размер для теней, устанавливаем его maskToBounds в NO, а затем добавляем представление содержимого в представление контейнера (например, shadowContainer).

0
задан Sukanya Purushothaman 17 January 2019 в 12:33
поделиться

2 ответа

только что отредактировал $('#CategoryName').on('change'... часть

var tableData = [{
    "Item Code": "1001",
    "Item Name": "Beverages",

    "Quantity": "0"

  },
  {
    "Item Code": "2003",
    "Item Name": "Juices",

    "Quantity": "0"
  },
  {
    "Item Code": "1004",
    "Item Name": "Soups",

    "Quantity": "0"

  },
  {
    "Item Code": "2005",
    "Item Name": "Cookies",

    "Quantity": "0"

  },

]

function addTable(tableData) {
  var col = Object.keys(tableData[0]);
  var countNum = col.filter(i => !isNaN(i)).length;
  var num = col.splice(0, countNum);
  col = col.concat(num);
  var table = document.createElement("table");
  var tr = table.insertRow(-1); // TABLE ROW.
  for (var i = 0; i < col.length; i++) {
    var th = document.createElement("th"); // TABLE HEADER.
    th.innerHTML = col[i];
    tr.appendChild(th);
    tr.classList.add("text-center");
    tr.classList.add("head")
  }
  for (var i = 0; i < tableData.length; i++) {
    tr = table.insertRow(-1);
    for (var j = 0; j < col.length; j++) {
      let tabCell = tr.insertCell(-1);
      var hiddenField = document.createElement("input");
      hiddenField.style.display = "none";
      var tabledata = tableData[i][col[j]];

      if (tableData[i]['Item Code'] === tableData[i][col[j]]) {
        tabCell.innerHTML = tabledata;
        hiddenField.setAttribute('name', 'Item_Code');
        hiddenField.setAttribute('value', tabledata);
        tabCell.appendChild(hiddenField);
      }
      if (tableData[i]['Item Name'] === tableData[i][col[j]]) {
        tabCell.innerHTML = tabledata;
        hiddenField.setAttribute('name', 'Item_Name');
        hiddenField.setAttribute('value', tabledata);
        tabCell.appendChild(hiddenField);
      }
      if (tableData[i]['Quantity'] === tableData[i][col[j]]) {
        var quantityField = document.createElement("input");
        quantityField.style.border = "none";
        quantityField.style["text-align"] = "center";
        quantityField.setAttribute('name', 'Quantity');
        quantityField.setAttribute('value', tabledata);
        quantityField.setAttribute('type', 'number');
        quantityField.classList.add("dataReset");
        tabCell.appendChild(quantityField);
        /* console.log(quantityField) */
      }
      if (j > 1)
        tabCell.classList.add("text-right");
    }
  }
  var divContainer = document.getElementById("HourlysalesSummary");
  divContainer.innerHTML = "";
  divContainer.appendChild(table);
  table.classList.add("table");
  table.classList.add("table-striped");
  table.classList.add("table-bordered");
  table.classList.add("table-hover");
}
addTable(tableData);

$('#CategoryName').on('change', function() {

  //you need to structure the data somehow 
  // and iterate over each input, if not , val() will act like .first().val() (just returning the value of the first input)
  var testing = [];
  $(".dataReset").each(function(u,itm){
   testing.push($(itm).val());
  });
  console.log(testing);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css">
<form action="InsertQuantityIndent" method="post" id="form1">
  <div class="row position-relative">
   
    <div class="col-lg-4">
      <h5>Category</h5>
      <select class="test" id="CategoryName" name="categoryCode">
        <option>All</option>
        <option>Cat1</option>
        <option>Cat2</option>
      </select>
    </div>
  </div>
  <br>
  <div class="table-responsive">
    <table class=" w-100" id=HourlysalesSummary></table>
  </div>
  <div>
    <button type="submit" id="save">
					<i class="fas fa-save"></i> Save
				</button>

  </div>
</form>

0
ответ дан john Smith 17 January 2019 в 12:33
поделиться

$(".dataReset") представляет собой список объектов jQuery. Вам нужно перебрать их:

$.each(".dataReset", (index,element) => console.log( $(element).val() ) )

jQuery $ .each документация

0
ответ дан Jeremy Thille 17 January 2019 в 12:33
поделиться
Другие вопросы по тегам:

Похожие вопросы: