0

Hi,
i am working on a billing page. Where the user will add item(s) to a bill, now the number of item(s) in a bill is not pre defined. So i am taking one input at a time, then adding them to a table in the same page. Now when the user will press the submit button the entire data stored in the table will be posted to another page for processing. But i am unable to get the table data. How to post the table data???

4
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by anirban1087
0

If you change the '"' on line 67 to a "$" and then put an open brace ({) at the end of line 234.

If you have no idea what I'm talking about, you'll get my point. Post your code.

0

Here is my code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>

<title>Billing & Inventory Management System ver 2.0 PURCHASE</title>

<meta name="Keywords" content="" />

<meta name="Description" content="" />

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<meta http-equiv="Content-Language" content="en-ie" />

<meta name="robots" content="all" />

<meta name="MSSmartTagsPreventParsing" content="true" />

<meta http-equiv="imagetoolbar" content="no" />

<meta name="copyright" content="Copyright (c) 2011 Anirban Ghosh" />

<meta name="author" content="" />

<meta name="Rating" content="General" />

<link rel="shortcut icon" href="" type="image/x-icon" />

<link rel="stylesheet" type="text/css" media="all" href="css/glob_nav.css" />

<link rel="stylesheet" type="text/css" media="all" href="css/template.css" />

<script language="javascript" type="text/javascript" src="js/datetimepicker.js"></script>

<script language="JavaScript" type="text/javascript">

function showtotal()

{

var total=0;

total+=this.value;

alert(total);

}

        function addRow(tableID,form) 

        {

            var table = document.getElementById(tableID);

            var rowCount = table.rows.length;

            var row = table.insertRow(rowCount);



 	    Item = form.select_itm.selectedIndex;

	    Result = form.select_itm.options[Item].text;



		var qt=form.qty1.value;

		var rt=form.pp.value;

		var qtrt=qt*rt;



            var cell1 = row.insertCell(0);

            var element1 = document.createElement("input");

            element1.type = "checkbox";

            cell1.appendChild(element1);

 

            var cell2 = row.insertCell(1);

            cell2.innerHTML = rowCount ;

 

            var cell3 = row.insertCell(2);

            var element2 = document.createElement("input");

            element2.type = "text";

            cell3.appendChild(element2);

            cell3.innerHTML = Result;



            var cell4 = row.insertCell(3);

            var element3 = document.createElement("input");

            element3.type = "text";

            cell4.appendChild(element3);

	    cell4.innerHTML = form.qty1.value;

	    

            var cell5 = row.insertCell(4);

            var element4 = document.createElement("input");

            element4.type = "text";

            cell5.appendChild(element4);

	    cell5.innerHTML = form.pp.value;

	    

            var cell6 = row.insertCell(5);

            var element5 = document.createElement("input");

            element5.type = "text";

            cell6.appendChild(element5);

	    cell6.innerHTML = form.sti.value;



            var cell7 = row.insertCell(6);

            var element6 = document.createElement("input");

            element6.type = "text";

            cell7.appendChild(element6);

	    cell7.innerHTML = form.mrp.value;

	    

            var cell8 = row.insertCell(7);

            var element7 = document.createElement("input");

            element7.type = "text";

            cell8.appendChild(element7);

 	    cell8.innerHTML = qtrt;

        }

 

function deleteRow(tableID) {

            try {

            var table = document.getElementById(tableID);

            var rowCount = table.rows.length;

 

            for(var i=0; i<rowCount; i++) {

                var row = table.rows[i];

                var chkbox = row.cells[0].childNodes[0];

                if(null != chkbox && true == chkbox.checked) {

                    table.deleteRow(i);

                    rowCount--;

                    i--;

                }

            }

            }catch(e) {

                alert(e);

            }

        }

    </script>

</head>





<body bgcolor="#f0f0f0">

<div id="header">

<?php

include('login_top.php');

?>

</div>

<?php

include('menu.php');

?>



<div id="body">

<div id="container">

<h1 align="center">PURCHASE FORM</h1>

<form id="pform" name="pform" method="post" action="purchase_process.php">

Supplier Name

<select name="select_sup" size="1">

					<option value="select" selected="selected">Select</option>

					<?php 

	include ('db_connect.php');

    

	$sql = "SELECT supp_name FROM suppliers ORDER BY supp_name;";

	$rs=mysql_query($sql);

	$count = @mysql_num_rows($rs);

	if($count > 0)

	$i=0;

	while ($i < $count) {

	$supp_name=mysql_result($rs,$i,"supp_name");

	

	?>

					<option ><?php echo $supp_name; ?></option>

<?php

$i++;

}

echo "</select>";

?>Bill No

<input name="bn" id="bn" type="text"  />



Bill Date

<td width="18%"><input id="date" type="text" name="date" size="25"><a href="javascript:NewCal('date','ddmmyyyy')"><img src="js/cal.gif" width="22" height="22" border="0" alt="Pick a date"></a></td>

		<td width="22%" style="">



Bill Total (Rs.)

<input name="bt" id="bt" type="text" readonly="readonly" />



<table id="inputTable" width="100%" border="1" cellspacing="0" cellpadding="1">

<tr>

<td width="150">Item</td>

<td width="50">Quantity</td>

<td width="50">PP (Rs.)</td>

<td width="50">STI (Rs.)</td>

<td width="50">MRP (Rs.)</td>

</tr>



<tr>

<td>

	<select name="select_itm" size="1">

		<option value="select" selected="selected">Select</option>

		<?php include ('db_connect.php');

    		$sql = "SELECT item_name FROM item ORDER BY item_name;";

		$rs=mysql_query($sql);

		$count = @mysql_num_rows($rs);

		if($count > 0)

			$i=0;

			while ($i < $count)

			 {

				$item_name=mysql_result($rs,$i,"item_name");

		?>

			<option ><?php echo $item_name; ?></option>

		<?php

				$i++;

			}

			echo "</select>";

		?>

</td>

<td>

	<input name="qty1" id="qty1" type="text" onChange=window.open("sl_sl_rd.php","Ratting","width=550,height=170,left=150,top=200,toolbar=1,status=1,this") >

</td>

<td>

	<input name="pp" id="pp" type="text" onChange="show_alert(this)" >

</td>

<td>

	<input name="sti" id="sti" type="text" onkeyup="integeronly(this)" >

</td>

<td>

	<input name="mrp" id="mrp" type="text"  >

</td>

  <td>

    <input name="add"  value="Add" id="add" onClick="addRow('dataTable',this.form)" type="button">

    <input name="cancel"  value="Cancel" id="cancel" onClick="reset()" type="button">

  </td>

</tr>

</table>

 

<table id="dataTable" border="1" cellspacing="0" cellpadding="1">

<tr>

<td width="50">Select</td>

<td width="50">SL. No.</td>

<td width="150">Item</td>

<td width="15">Quantity</td>

<td width="25">PP</td>

<td width="25">STI</td>

<td width="25">MRP</td>

<td width="25">Amount</td>

</tr>



</table>

<table>

<tr>

<td width="25"><input type="button" value="Submit" onclick="submit()"/></td>

<td><INPUT type="button" id="delete" value="Delete Item" onclick="deleteRow('dataTable')" /></td>

</tr>

</table>

</form>

<br class="clearfloat" />

<div id="footer">

<p></p>

</div>

</body></html>
0
$data = $_POST['input_field_name'];

Catch the data with the above in the page that you want to process those data.

0
$data = $_POST['input_field_name'];

This code will work only if i am taking the input from a field. But here i am generating a table from the user input. Then would like to post that particular table to another page.

0

use array to store the values(i.e. for textbox and other's name attribute define it as array)....it will work fine...it will dynamically increase the element and on submitting data use the foreach statement to get the end of the data....

Edited by tomato.pgn: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.