jquery - Pass all needed values with Javascript -
i using 2 table print values database. use script select specific cells row. part works well. have created bootstrap modal, , have retrieve values modal , insert values in database. script use select specific cells in different rows.
<script> $(".addvalues").click(function () { $('#selection').show(); var $this = $(this), mycol = $this.closest("td"), myrow = mycol.closest("tr"), targetarea = $("#selection"); var qte_input = (' <input type="text" name="kolicina" id="kolicina" placeholder="kg / m" size="10"/>'); targetarea.prepend($("td.data-id", myrow).text() + qte_input +"<hr />"); }); </script>
html code
<td class='data-id'><?='b-'. $r['id']?> </td>
selected values print in div
<div id="selection"> </div>
second script values modal, script works good.
<script type="text/javascript"> $(function(){ $('#myformsubmit').click(function(e){ e.preventdefault(); var x = document.getelementbyid("kolicina").value; var y = document.getelementbyid("sifra").value; var f = document.getelementbyid("firma").value; var k = document.getelementbyid("kontakt").value; var = document.getelementbyid("adresa").value; var t = document.getelementbyid("tel").value; var e = document.getelementbyid("email").value; var n = document.getelementbyid("napomena").value; var kolicina = {kolicina:x}; var sifra = {sifra:y}; var firma = {firma:f}; var kontakt = {kontakt:k}; var adresa = {adresa:a}; var tel = {tel:t}; var email = {email:e}; var napomena = {napomena:n}; $.ajax({ url: 'materijali-script.php', data: arr, type: 'post', }); }); </script>
i got needed values second script (from modal). need selected values first script. values should in array every selection hold values id , quantity. give me advice how can send needed values
here on image, example values selected table, added value after.
i want pass values image values modal
you may useful below code:
<script type="text/javascript"> $(function(){ $('#myformsubmit').click(function(e){ e.preventdefault(); var x = document.getelementbyid("kolicina").value; var y = document.getelementbyid("sifra").value; var f = document.getelementbyid("firma").value; var k = document.getelementbyid("kontakt").value; var = document.getelementbyid("adresa").value; var t = document.getelementbyid("tel").value; var e = document.getelementbyid("email").value; var n = document.getelementbyid("napomena").value; var kolicina = {kolicina:x}; var sifra = {sifra:y}; var firma = {firma:f}; var kontakt = {kontakt:k}; var adresa = {adresa:a}; var tel = {tel:t}; var email = {email:e}; var napomena = {napomena:n}; var arr=[]; arr.push( {"kolicina":document.getelementbyid("kolicina").value}, {"sifra":document.getelementbyid("sifra").value}, {"firma":document.getelementbyid("firma").value}, {"kontakt":document.getelementbyid("kontakt").value} ); $.ajax({ url: 'materijali-script.php', data: arr, type: 'post', }); }); }); </script>
Comments
Post a Comment