Home how to get another value with ajax from foreach table
Reply: 0

how to get another value with ajax from foreach table

user2240
1#
user2240 Published in June 21, 2018, 6:26 am

I have table from foreach, in this table i create submit with ajax (id="detail"), but why when i submit i just get first row, when i click second row value, i get first row value not second row value ?

<form action="<?php echo base_url() ?>index.php/stock_opname/proses_detail" method="post">
        <table class="table table-striped">
            <thead>
            <tr>
                <th>No</th>
                <th>SO No</th>
                <th>Opname Date</th>
                <th>Warehouse</th>
                <th>Type</th>
                <th>Approve</th>
                <th>Close period</th>
                <th>Detail</th>
            </tr>
            </thead>
            <tbody>
            <?php $no=1; foreach ($show as $key) { ?>
            <tr>
                    <td><?php echo $no ?></td>
                    <td><input type="text" id="sono" value="<?php echo $key->sono ?>"></td>
                    <td><input type="text" id="opnamedate" value="<?php echo $key->opnamedate ?>"></td>
                    <td><input type="text" id="warehousecode" value="<?php echo $key->warehousecode ?>"></td>
                    <td><input type="text" id="stocktypeid" value="<?php echo $key->stocktypeid ?>"></td>
                    <td></td>
                    <td></td>
                    <td><a href="#" id="detail" class="btn btn-info">Detail</a></td>
            </tr>
            <?php $no++;} ?>
            </tbody>
        </table>
    </form>


<script type="text/javascript">
    //Ajax Load data from ajax
    $(document).on('click', '#detail', function(){

            var sono = $('#sono').val();
            var opnamedate = $('#opnamedate').val();
            var wh = $('#warehousecode').val();
            var stocktypeid = $('#stocktypeid').val();

            alert(sono);

        });

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.335922 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO