Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2012
    Location
    Delhi
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to take values of html rows using jquery?

    Hi,
    I want to fetch all data of these 29 rows (screenshot attached) out of which 25 rows coming form database and 4 rows for extra use,

    here is my code please suggest , how i can take these values and send in other page.
    <html >
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>REGISTRATION FORM</title>
    <script language="javascript" type="text/javascript" src="js/jquery.min.js"></script>
    </head>
    <body >
    <div>

    <form id="registration" name="registration" method="post" action="">

    <?php
    require_once("config.php");
    $query_for_result=mysqli_query($con,"SELECT * FROM mytable ORDER BY id ASC");
    $num=mysqli_num_rows($query_for_result);
    mysqli_close($con);

    ?>
    <table > <tr>
    <td >Sl.No..</td>
    <td >Item</td>
    <td >Paper</td>
    <td >Finish</td>
    <td >Price</td>
    <td >Vat</td>
    <td >Total Amount</td>

    </tr>

    <?php

    $i=0;

    while($row = mysqli_fetch_assoc($query_for_result))
    {
    $f1=$row['id'];
    $f2=$row['album_name'];
    $f3=$row['paper_used'];
    $f4=$row['finishing'];
    $f5=$row['price'];
    $f6=$row['vat'];
    $f7=$row['total_amt'];

    $id=$i+1;
    //echo $id;
    ?>
    <tr>
    <td ><input id="slno" name="slno" type="text" value="<?php echo $f1; ?>" style="width:20px;"/></td>
    <td ><input id="album_name" name="album_name" value="<?php echo $f2; ?>" type="text" style="width:150px;"/></td>
    <td ><input id="paper_used" name="paper_used" type="text" value="<?php echo $f3; ?>" style="width:85px;"/></td>
    <td ><input id="finishing" name="finishing" value="<?php echo $f4; ?>" type="text" style="width:90px;"/></td>
    <td ><input id="price" value="<?php echo $f5; ?>" name="price" type="text" style="width:25px;"/></td>
    <td ><input id="vat" value="<?php echo $f6; ?>" name="vat" type="text" style="width:35px;"/></td>
    <td ><input id="total_amt" name="total_amt" value="<?php echo $f7; ?>" type="text" style="width:50px;"/></td>

    </tr>
    <?php
    $i++;

    }


    ?>
    <tr>
    <td ><input id="slno" name="slno" type="text" value="26" style="width:20px;"/></td>
    <td ><input id="album_name" name="album_name" value="" type="text" style="width:150px;"/></td>
    <td ><input id="paper_used" name="paper_used" type="text" value="" style="width:85px;"/></td>
    <td ><input id="finishing" name="finishing" value="" type="text" style="width:90px;"/></td>
    <td ><input id="price" value="" name="price" type="text" style="width:25px;"/></td>
    <td ><input id="vat" value="" name="vat" type="text" style="width:35px;"/></td>
    <td ><input id="total_amt" name="total_amt" value="" type="text" style="width:50px;"/></td>


    </tr>
    <tr>
    <td ><input id="slno" name="slno" value="27" type="text" style="width:20px;"/></td>
    <td ><input id="album_name" name="album_name" value="" type="text" style="width:150px;"/></td>
    <td ><input id="paper_used" name="paper_used" type="text" value="" style="width:85px;"/></td>
    <td ><input id="finishing" name="finishing" value="" type="text" style="width:90px;"/></td>
    <td ><input id="price" value="" name="price" type="text" style="width:25px;"/></td>
    <td ><input id="vat" value="" name="vat" type="text" style="width:35px;"/></td>
    <td ><input id="total_amt" name="total_amt" value="" type="text" style="width:50px;"/></td>


    </tr>
    <tr>
    <td ><input id="slno" name="slno" value="28" type="text" style="width:20px;"/></td>
    <td ><input id="album_name" name="album_name" value="" type="text" style="width:150px;"/></td>
    <td ><input id="paper_used" name="paper_used" type="text" value="" style="width:85px;"/></td>
    <td ><input id="finishing" name="finishing" value="" type="text" style="width:90px;"/></td>
    <td ><input id="price" value="" name="price" type="text" style="width:25px;"/></td>
    <td ><input id="vat" value="" name="vat" type="text" style="width:35px;"/></td>
    <td ><input id="total_amt" name="total_amt" value="" type="text" style="width:50px;"/></td>

    </tr>
    <tr>
    <td ><input id="slno" name="slno" value="29" type="text" style="width:20px;"/></td>
    <td ><input id="album_name" name="album_name" value="" type="text" style="width:150px;"/></td>
    <td ><input id="paper_used" name="paper_used" type="text" value="" style="width:85px;"/></td>
    <td ><input id="finishing" name="finishing" value="" type="text" style="width:90px;"/></td>
    <td ><input id="price" value="" name="price" type="text" style="width:25px;"/></td>
    <td ><input id="vat" value="" name="vat" type="text" style="width:35px;"/></td>
    <td ><input id="total_amt" name="total_amt" value="" type="text" style="width:50px;"/></td>


    </tr>
    <tr>

    <td colspan="7" ><input name="save" value="Save" id="save" type="button" style="width:83px;" /></td>

    </tr>
    </table>
    </form>

    </div>


    </body>
    </html>
    How to take values of html rows using jquery?-registration-form-3.jpg

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,084
    Thanks
    23
    Thanked 592 Times in 591 Posts
    Easiest way is to give the table an ID
    This gets the first row first cell
    document.getElementById("my_table").rows[0].cells[0].innerHTML
    Which is Sl.No..

    =============================================

    But Easier still is to use your DB and just get those values from it when the other page loads. If you need to get the info in the four last row then use above method and use sessions to send the 4.
    Last edited by sunfighter; 03-11-2014 at 03:13 PM.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    The post lacks some details but I think the user can modify the data in the table and the OP might want that modified data to be passed to the other page. I don't know what is that other page but it seems that the registration form submits to itself and not to that other page. If so, then after registration is successful and saved to the database, then that other page can fetch the latest data stored from the database.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •