jeudi 5 septembre 2019

get value array data from html to javascript at laravel

I want to make a function in js where js takes value from data array html

i using laravel 5.8, i want, when the button clicked, data array is called and placed into a new form input

<div class="row">
  @foreach ($product as $p)
    <div class="col-md-2 stock ml-4 mt-3">
       <div class="mt-1">
          <a onclick="addlist()"> <img height="50px" class="img-thumbnail"
           src="">
              <p id="qty"></p>
              <p id="code"></p>
          </a>
       </div>
     </div>
  @endforeach
</div>

<div class="row">
   <input type="text" id="qtylist">
   <input type="text" id="codelist">
</div>

<script>
function addlist(){ 
    var qty = document.getElementById('qty').value;
    var code = document.getElementById('code').value;

   for(var i=0; i>qty.length; i++){
     var qtyList = qty[i];
     var codeList = code[i]
     document.getElementById('qtylist').value = qtyList
     document.getElementById('codelist').value = codeList
   }
}
</script>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire