how to pass value of different rows from a loop to next page in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • malika
    New Member
    • Apr 2013
    • 7

    #1

    how to pass value of different rows from a loop to next page in php

    hi everyone my problem is this that i dynamically creted rows of table on the basis user input. Now each row contain textbox,comboxb ox on selcting value from combobox n entering value in textbox from first three column ,result will display.on passing these selected n entered value on next page only the last row values moves to next page .i want to pass all loop values to next page
    Code:
    javascripting code
    <script>
     function getText3(row){
                var in1=document.getElementById('in1-' + row).value;
                var in2=document.getElementById('in2-' + row).value;
                var in4=document.getElementById('in4-' + row).value;
                var in3=(in1*in2*in4*30)/1000;
                document.getElementById('in3-' + row).value=in3.toFixed(2 );
    
        }
    
    </script>
    </head>
    table code 
    <?php
    $de=$_POST['text123'];
    echo $de;
    ?>
                           
    <body>
    <form action="kl2.php" method="post" >
           <table border="1" align="center" id="wr123">
        <tr>
            <th>WAS</th>
            <th>NO.</th>
            <th>AVERAGE</th>
            <th>APPROX</th>
        </tr>
        <?php
    
        for ($i = 1; $i <= $de; $i++) {
        ?>
        <tr>
            <td>Tube</td>
            <td>
                <select id="in4-<?php echo $i; ?>" name="t1" onclick="getText3(<?php echo $i; ?>)" >
                    <option value="0">0</option>
                    <option value="12">12</option>
                    <option value="18">18</option>
                    <option value="24">24</option>
                    <option value="75">75</option>
                </select>
            </td>
            <td>
                <input type="text" name="t2" id="in1-<?php echo $i; ?>" onblur="getText3(<?php echo $i; ?>)" />
            </td>
            <td>
                <select name="a1" id="in2-<?php echo $i; ?>" onclick="getText3(<?php echo $i; ?>)" >
                    <option value="0">0</option>
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                    <option value="4">4</option>
                    <option value="5">5</option>
                    <option value="6">6</option>
                    <option value="7">7</option>
                    <option value="8">8</option>
                </select>
            </td>
            <td>
                <input type="text" id="in3-<?php echo $i; ?>" name="username" readonly="readonly" />
            </td>
            <td>
        </tr>
        <?php } ?>
    	<input type="submit" name="submit" />
    
        </table>
    	</form>
    	kl2.php
    <?php
    @$a=$_POST['t1'];
    echo @$a;
    $sl = $_POST['t2'];
    echo $sl;
    $b=$_POST['a1'];
    echo $b;
    $c=$_POST['username'];
    echo $c;
    
    
    ?>
    on submit click it only display the last row values i.e if user enter 3 ,3 rows get displayed after clicking the submit only the data of last row display
    Last edited by Rabbit; May 25 '13, 05:07 PM. Reason: Added closing code tag.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    That's because all your form fields have the same name.

    Comment

    Working...