I want to pass selected value on invoice.php file using jquery. After sending value on invoice.php file. I want to show invoice.php file echo result on index.php page selected input box. Like an example: If anyone select Item then rate show on rate input box. Here is my code and image
01.jpg
index.php file code:
invoice.php file code:HTML Code:<html> <head> <title>Invoice</title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".iteam").change(function(){ calculate(); }); }); function calculate() { var iteam = []; $(".iteam").each(function() { var num=(this.value); iteam.push(num); }); $('input[name=rate]').each(function(i){ $.get( '/invoice_final_2.php', {'product':iteam[i]}, function(data) { $(this).html(data); }); }); } </script> <style type="text/css"> table { border: 1px solid black; border-bottom: none; width: 300px; } td { border-left: 1px solid black; border-bottom: 1px solid black; padding:5px 5px 5px 5px; } #first { border-left: none; border-bottom: 1px solid black; } </style> </head> <body> <form method='post' name='form1' action='welcome.php'> <table cellpadding="0" cellspacing="0"> <tr> <td id="first">Iteam</td> <td>Rate</td> </tr> [PHP] <?php $num=4; for ($i=0; $i<$num; $i++) { echo " <tr> <td id='first'> <select class='iteam' name='iteam'> <option>Select one</option> <option>Deluxe Plan</option> <option>Premium Plan</option> <option>Standard Plan</option> <option>Economy Plan</option> </select> </td> <td><input class='rate' type='text' name='rate'/></td> </tr>"; } ?>[/PHP] </table> </form> </body> </html>
I am trying so hard to solve this problem. But I can't find out the problem. So pls pls pls... help me.PHP Code:<?php
include "dbconnect.php";
$product=$_GET['product'];
$query="select * from iteam where iteam_name='$product'";
$result=mysql_query or die (mysql_error());
$row=mysql_fetch_assoc($result);
$rate=$row['rate'];
echo "$rate";
?>


Reply With Quote

Bookmarks