A Database Error Occurred In codeigniter Error Number: 1048 - php

i have problem at the time of input data to the database
this is error message
A Database Error Occurred
Error Number: 1048
Column 'username_member' cannot be null
INSERT INTO member (id_member, username_member,
password_member, nama_member, jk_member, hp_member,
alamat_member, email_member) VALUES (NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL)
Filename: C:/AppServ/www/PROJEK/system/database/DB_driver.php
Line Number: 691
my controller
function tambah()
{
$data = array(
'aksi' => site_url('member/tambah_aksi'),
'id_member' => set_value('id_member'),
'username_member' => set_value('username_member'),
'password_member' => set_value('password_member'),
'nama_member' => set_value('nama_member'),
'jk_member' => set_value('jk_member'),
'hp_member' => set_value('hp_member'),
'alamat_member' => set_value('alamat_member'),
'email_member' => set_value('email_member'),
'button' => 'DAFTAR'
);
$this->load->view('Utama/member_form', $data);
}
function tambah_aksi()
{
$data = array(
'id_member' => $this->input->post('id_member'),
'username_member' => $this->input->post('username_member'),
'password_member' => $this->input->post('password_member'),
'nama_member' => $this->input->post('nama_member'),
'jk_member' => $this->input->post('jk_member'),
'hp_member' => $this->input->post('hp_member'),
'alamat_member' => $this->input->post('alamat_member'),
'email_member' => $this->input->post('email_member')
);
$this->member_model->tambah_data($data);
redirect('Login_member');
}
View
<h3> FORM <i class="icon-arrow-left"></i> LANJUT BERBELANJA </h3> <hr class="soft"/> <table class="table table-bordered">
<tr><th> FORM DAFTAR MEMBER </th></tr>
<form action="<?php echo $aksi; ?>" method="get" class="form-horizontal" enctype="multipart/form-data">
<tr>
<td>
<div class="control-group">
<label class="control-label" for="inputUsername">Username</label>
<div class="controls">
</td>
<td>
<input type="text" name="username_member" class="form-control" placeholder="Inputkan Username" value="">
</div>
</div>
</td>
<tr>
<td>
<div class="control-group">
<label class="control-label" for="inputPassword1">Password</label>
<div class="controls">
</td>
<td>
<input type="password" name="password_member" placeholder="Password" value="">
</div>
</div>
</td>
</tr>
<tr>
<td>
<div class="control-group">
<label class="control-label" for="inputPassword1">Nama Member</label>
<div class="controls">
</td>
<td>
<input type="text" name="nama_member" placeholder="ex : Eden Hazard" value="">
</div>
</div>
</td>
</tr>
<tr>
<td>
<div class="control-group">
<label class="control-label" for="inputPassword1">Jenis Kelamin</label>
<div class="controls">
</td>
<td>
<input type="radio" name="jk_member" value="Laki">Pria
<br>
<input type="radio" name="jk_member" value="Wanita">Wanita
</div>
</div>
</td>
</tr>
<tr>
<td>
<div class="control-group">
<label class="control-label" for="inputPassword1">No Hp</label>
<div class="controls">
</td>
<td>
<input type="text" name="hp_member" placeholder="ex : 08127516331" value="">
</div>
</div>
</td>
</tr>
<tr>
<td>
<div class="control-group">
<label class="control-label" for="inputPassword1">Alamat Lengkap</label>
<div class="controls">
</td>
<td>
<input type="text" name="alamat_member" placeholder="ex : perum pandau blok c.19 no.16, Pekanbaru, Riau" value="">
</div>
</div>
</td>
</tr>
<tr>
<td>
<div class="control-group">
<label class="control-label" for="inputPassword1">Email</label>
<div class="controls">
</td>
<td>
<input type="text" name="email_member" placeholder="ex : randy#yahoo.com" value="">
</div>
</div>
</td>
</tr>
<tr>
<td>
<input type="hidden" name="id_member" value="<?php echo $id_member; ?>">
<button class="btn btn-primary" type="submit"><?php echo $button; ?></button>
</td>
</tr>
</form>

You want to change your forms method from get to post as you are processing POST data.
So your line
<form action="<?php echo $aksi; ?>" method="get" class="form-horizontal" enctype="multipart/form-data">
Change the get to post for your method.
<form action="<?php echo $aksi; ?>" method="post" class="form-horizontal" enctype="multipart/form-data">
See how that flies.

Related

bootstrap table and form not visible in php

I am trying to get some data from a database and show them in a bootstrap table in php. but the php file only shows navigation bar. it does not show the table or the form. I have checked the connection which is fine. even if connection was wrong it should at least show the table headers and form labels. which it does not.
<?php
include 'adminlogincheck.php';
include 'dbcarsconfig.php';
include 'adminheader.php';
?>
<div class="container-fluid">
<div class="row justify-content-center">
<div class="col-md-8">
<!-- session response-->
<?php if(isset($_SESSION['response'])){ ?>
<div class="alert alert-<?= $_SESSION['res_type']; ?> alert-dismissible">
<button type="button" class="close" data-dismiss="alert">×</button>
<?= $_SESSION['response']; ?>
</div>
<?php } unset($_SESSION['response']);?>
<?php
$query="SELECT * FROM cars";
$stmt=$conn->prepare($query);
$stmt->execute();
$result=$stmt->get_result();
?>
<table class="table table-dark table-striped table-hover">
<thead>
<tr>
<th>Thumbnail</th>
<th>ID</th>
<th>Reg no</th>
<th>Make</th>
<th>Model</th>
<th>Price</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php while($row=$result->fetch_Assoc()){?>
<tr>
<td><img src="<?= $row['image1']?>" width="100" height="50"></td>
<td><?= $row['id']?></td>
<td><?= $row['carreg']?></td>
<td><?= $row['make']?></td>
<td><?= $row['model']?></td>
<td><?= $row['price']?></td>
<td> Edit/View</td>
<td> Delete</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<div class="col-md-4">
<form action="actioncars.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?= $id; ?>">
<div class="form-group">
<input type="text" name="carreg" class="form-control" placeholder="Enter car reg no" value="<?= $carreg; ?>" required>
</div>
<div class="form-group">
<input type="text" name="make" class="form-control" placeholder="Make of car" value="<?= $make; ?>" required>
</div>
<div class="form-group">
<input type="text" name="model" class="form-control" placeholder="Model" value="<?= $model; ?>" required>
</div>
<div class="form-group">
<input type="text" name="price" class="form-control" placeholder="Price" value="<?= $price; ?>" required>
</div>
<div class="form-group">
<input type="hidden" name="oldimage" value="<?= $image1; ?>">
<input type="file" name="image1" class="custom-file">
<img src="<?= $image1; ?>" width="120" class="img-thumbnail">
</div>
<div class="form-group">
<?php if ($update==true){ ?>
<input type="submit" name="update" class="btn btn-success btn-block" value="Update record">
<?php } else { ?>
<input type="submit" name="add" class="btn btn-primary btn-block" value="Add record">
<?php } ?>
</div>
</form>
</div>
</div>
</div>
<?php include 'footer.php'; ?>

Laravel data not going appropriately into the database

What i need is if i get first element id of MOB/TR/1743 then press the mark button data which relevant to that id must go the database.
This is what should in the database.
But this is what i'm getting into the database. That means getting another column data into database.
Here is the view of that.
<div class="row">
<section id="feature" class="section-padding wow fadeIn delay-05s">
<div class="container">
<div class="row">
<div class="col-md-12 col-sm-6 col-xs-12">
<div class="wrap-item text-center">
<div class="jumbotron">
<div class="item-img">
<img src="images/ser02.png">
</div>
<div class="form-group">
<form action="search" method="post" class="form-inline">
<select name="institute" id="institute">
<option selected="selected" value="id">Trainee Id</option>
<option value="full_name">Trainee Name</option>
<label for="Search">Name</label>
</select>
<input type="text" name="search" /><br>
<input type="hidden" value="{{ csrf_token() }}" name="_token" />
<input type="submit" name="submit" value="Search">
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
<div class="col-md-12 col-sm-6 col-xs-12">
<div class="panel panel-default">
<div class="panel-body">
<table class="table table-striped">
<thead>
<th>Trainee ID</th>
<th>Name with Initials</th>
<th>Time</th>
<th>Mark Here!</th>
</thead>
<tbody>
<form action="{{route('TraineeAttendance.store')}}" method="post" >
{{ csrf_field() }}
#foreach($items as $item)
<tr>
<td>
<div class="form-group">
<input type="text" name="trainee_id" class="form-control" value="{{ $item->trainee_id }}">
</div>
</td>
<td>
<div class="form-group">
<input type="text" name="name" class="form-control" value="{{ $item->name_with_initials }}">
</div>
</td>
<td>
<label><input type="checkbox" name="time" id="time" value="time"> Time</label>
</td>
<td>
<input type="submit" class="btn btn-info">
</td>
</tr>
#endforeach
</form>
</tbody>
</table>
</div>
</div>
</div>
Why i`m getting wrong data?
try this hope it helps
#foreach($items as $item)
<form action="{{route('TraineeAttendance.store')}}" method="post" >
{{ csrf_field() }}
<tr>
<td>
<div class="form-group">
<input type="text" name="trainee_id" class="form-control" value="{{ $item->trainee_id }}">
</div>
</td>
<td>
<div class="form-group">
<input type="text" name="name" class="form-control" value="{{ $item->name_with_initials }}">
</div>
</td>
<td>
<label><input type="checkbox" name="time" id="time" value="time"> Time</label>
</td>
<td>
<input type="submit" class="btn btn-info">
</td>
</tr>
</form>
#endforeach

Insert not working correctly in codeigniter

I am trying to insert data into the database and my code does add a new row but all the values are null. I don't know what's causing it. The view is inside a modal in html. Here's my code: Thanks for your help
Controller:
public function addItem(){
$save = array(
'inventoryID' => $this->input->post('rfid'),
'masterCode' => $this->input->post('masterCode'),
'itemName' => $this->input->post('itemName'),
'colorName' => $this->input->post('colorName'),
'location' => $this->input->post('location'),
'itemCategory' => $this->input->post('itemCategory'),
'materialDescription' => $this->input->post('materialDescription'),
'supplier' => $this->input->post('supplier'),
'itemDescription' => $this->input->post('itemDescription'),
'comments' => $this->input->post('comments'),
'itemCode' => $this->input->post('itemCode'),
'colorCode' => $this->input->post('colorCode')
);
$this->searchModel->form_insert($save);
//load the header
$this->load->view('base.php',$save);
//load the page
redirect('Search');
//load the footer
$this->load->view('footer.php',$save);
}
Model:
function form_insert($data){
// Inserting in Table(inventory) of Database(library)
$this->load->database();
$this->db->insert('inventory', $data);
$inventoryID = $this->db->insert_id();
}
View:
<div id="addItem" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<form method ="post" action= "<?php echo site_url("Search/addItem"); ?>">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Add an Item</h4>
</div>
<div class="modal-body">
<form role="form">
<table>
<tr>
<td><input type="text" name="rfid" placeholder="RFID" required/></td>
<td><input type="text" name="itemCode" placeholder="Item Code" required/></td>
<td><input type="text" name="masterCode" placeholder="Master Code" /></td>
</tr>
<tr>
<td><input type="text" name="itemName" placeholder="Item Name" required/></td>
<td><input type="text" name="colorCode" placeholder="Color Code" /></td>
<td><input type="text" name="colorName" placeholder="Color Name" /></td>
</tr>
<tr>
<td><input type="text" name="location" placeholder="Location" required/></td>
<td><input type="text" name="makelocation" placeholder="Location Made" required/></td>
<td><input type="text" name="itemCategory" placeholder="Item Category" /></td>
</tr>
<tr>
<td><input type="text" name="materialDescription" placeholder="Material Description" /></td>
<td><input type="text" name="supplier" placeholder="Supplier/Vendor" required/></td>
<td><input type="text" name="checkoutAllowed" placeholder="Checkout Allowed" /></td>
</tr>
</table>
<div class="row personal-info">
<div class="col-sm-4">
<div class="form-group">
<textarea name="itemDescription" placeholder="Insert information regarding the weather this item is suitable for and where it is used"></textarea>
<textarea name="Comments" placeholder="Additional Coments on the Item"></textarea>
</div>
</div>
</div>
</form>
</div>
<div class="modal-footer" style="text-align:center;">
<input class="btn btn-primary" name="addItem" value="Add Item">
</div>
</form>
</div>
</div>
</div>
The problem is that you do not actually "submit" the form data. Your button links to the correct controller/method but does not send any data to the controller when you use a link, i.e. <a href=.... You need a submit button.
The change is quite simple. Change the code for the button as follows.
<div class="modal-footer" style="text-align:center;">
<input type="submit" class="btn btn-primary" name="addItem" value="Add Item">
</div>
There is another issue. You have two <form> tags.
Remove the line
<form method ="post" action="<?php echo site_url("Search/addItem"); ?>">
And change the line
<form role="form">
to
<form method="post" action="<?php echo site_url("Search/addItem"); ?>" role="form">
You also need to remove the extra form close tag two lines above the button's code. Nested <form>s are not allowed. And you need to move the closing tag for <div class="modal-content"> So to make it more clear here is what your view should finally look like.
<div id="addItem" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Add an Item</h4>
</div>
<div class="modal-body">
<form method ="post" action= "<?php echo site_url("Search/addItem"); ?>" role="form">
<table>
<tr>
<td><input type="text" name="rfid" placeholder="RFID" required/></td>
<td><input type="text" name="itemCode" placeholder="Item Code" required/></td>
<td><input type="text" name="masterCode" placeholder="Master Code" /></td>
</tr>
<tr>
<td><input type="text" name="itemName" placeholder="Item Name" required/></td>
<td><input type="text" name="colorCode" placeholder="Color Code" /></td>
<td><input type="text" name="colorName" placeholder="Color Name" /></td>
</tr>
<tr>
<td><input type="text" name="location" placeholder="Location" required/></td>
<td><input type="text" name="makelocation" placeholder="Location Made" required/></td>
<td><input type="text" name="itemCategory" placeholder="Item Category" /></td>
</tr>
<tr>
<td><input type="text" name="materialDescription" placeholder="Material Description" /></td>
<td><input type="text" name="supplier" placeholder="Supplier/Vendor" required/></td>
<td><input type="text" name="checkoutAllowed" placeholder="Checkout Allowed" /></td>
</tr>
</table>
<div class="row personal-info">
<div class="col-sm-4">
<div class="form-group">
<textarea name="itemDescription" placeholder="Insert information regarding the weather this item is suitable for and where it is used"></textarea>
<textarea name="Comments" placeholder="Additional Coments on the Item"></textarea>
</div>
</div>
</div>
<div class="modal-footer" style="text-align:center;">
<input type="submit" class="btn btn-primary" name="addItem" value="Add Item">
</div>
</form>
</div>
</div>
</div>
</div>

how can i show only selected checkbox productcode and price in codeIgniter

My view is like i want to show the selected textbox price and code to the controller
how can i do this
<div>
<!--second line start-->
<?php
foreach ($enq_info as $ei) {
echo form_open_multipart("Quotation/prepareQuote2/$ei->eid");
if (!empty($quote_data)) {
?>
<input name="quote_check" value="1" type="text" class="form-control">
<?php
} else {
?>
<input name="quote_check" value="no" type="text" class="form-control">
<?php
}
?>
<div class="form-group">
<div class="col-sm-2">
<label for="firstname">Enquiry Id</label>
<input name="e_id" id="e_id" value="<?php echo $ei->eid;?>" type="text" class="form-control">
</div>
<div class="col-sm-3">
<label for="lastname">Company Name</label>
<input type="text" name="company_name" id="company_name" value="<?php echo $ei->company_name;?>" class="form-control" />
</div>
<div class="col-sm-3">
<label for="lastname">Contact Person</label>
<input type="text" name="c_person" id="c_person" value="<?php echo $ei->c_person;?>" class="form-control"/>
</div>
<div class="col-sm-4">
<label>Address</label>
<textarea class="form-control" id="address" name="address" value="<?php echo $ei->address;?>"><?php echo $ei->address;?></textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-3">
<label for="firstname">Attn Department</label>
<textarea class="form-control" id="dept" name="dept" value="">
<?php
echo $ei->c_person." Tel ";
if(empty($ei->p_contact))
echo $ei->c_contact;
else
echo $ei->p_contact;
?>
</textarea>
</div>
<div class="col-sm-3">
<label for="lastname">Quotation For</label>
<select id="quotation_type" name="quotation_type" class="form-control m-b">
<option value="Q_Manager">Q-Manager Quote</option>
<option value="Q_Master">Q-Master Quote</option>
<option value="Q_Manager_repair">Q-Manager Repair Quote</option>
</select>
</div>
<div class="col-sm-3">
<label for="lastname">Discount</label>
<textarea class="form-control" id="discount" name="discount"></textarea>
</div>
<div class="col-sm-3">
<label for="lastname"></label><br><br>
<input type="submit" class="btn btn-success" id="default_quote" value="Generate Default Quote" onClick="rerurn disable1();"/>
</div>
</div>
<div id="showquote">
<div class="row">
<div class="hpanel">
<div class="panel-body">
<div class="col-md-12">
<table class="table table-bordered table-striped">
<tr>
<td>Product Name</td>
<td>Product Code</td>
<td>Price</td>
<td>Action</td>
</tr>
<?php
// print_r($quote_data);
foreach ($product_data as $qd) {
?>
<tr>
<td><?php echo $qd->cp_name;?></td>
<td><?php echo $qd->cp_code;?></td>
<td>
<input type="text" name="product_price[]" value="<?php echo $qd->p_price;?>">
</td>
<td>
<input type="checkbox" name="product_name[]" value="<?php echo $qd->cp_name;?>" checked/>
</td>
</tr>
<?php
}
?>
</table>
</div>
</div>
</div>
</div>
</div>
<?php echo form_close(); ?>
<br><br>
<!--for new manual quote-->
<?php
}
?>
<!--third line start-->
how can i send the selected values price and also product code to the controller
just add the product code - product price with comma seperated in a hidden field like below
12-20000,13-30000,14-200 and so on
and once received in controller process it with explode or other way.
hopes you understood.

Dynamic form field with jquery not post values to php

i had form that is add some fields via jquery when i click " add new " button it will update a dom , with input fields . Input fields are using a array as a name , when i click submit button , values did not post to php, only static form values are posted but not dynamically generated input values .
My fiddle is http://jsfiddle.net/4L9Rc/
It will demonstrate clearly how is my form working .
HTML
<div class="row">
<div class="col-md-12">
<form method="POST" action="http://fabtech.com/invoices/create" accept-charset="UTF-8" role="form" class="form-horizontal re-form form-inv"><input name="_token" type="hidden" value="aLngVzB1UIlY6cEedbAh55tirXGGkYJl78BL0CRN"> <legend>Invoice Details</legend>
<div class="col-md-6">
<div class="form-group">
<label class="col-md-4 control-label">Invoice No</label>
<div class="col-md-7">
<input type="text" placeholder="Enter invoice no" class="form-control" name="inv_no" value=""">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Invoice date</label>
<div class="col-md-7">
<input type="text" placeholder="Enter text" class="form-control date-pic" name="inv_date" value="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Customer</label>
<div class="col-md-7">
<select class="form-control" name="inv_customer">
<option value="">- Select Customer -</option>
<option value="suresh">suresh</option>
<option value="ABC210">ABC210</option>
<option value="QWERTy123DF">QWERTy123DF</option>
<option value="CUS002">CUS002</option>
<option value="CUS0023">CUS0023</option>
<option value="CUS003">CUS003</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">PO No</label>
<div class="col-md-7">
<input type="text" placeholder="Enter text" class="form-control" name="po_no" value="">
</div> </div>
<div class="form-group">
<label class="col-md-4 control-label">PO date</label>
<div class="col-md-7">
<input type="text" placeholder="DD/MM/YYY" class="form-control date-pic" name="po_date" value="">
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="col-md-4 control-label">Vendor code</label>
<div class="col-md-7">
<input type="text" placeholder="Enter Vendor Code" class="form-control" name="vendor_code" value="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">75% abatement value</label>
<div class="col-md-1">
<input type="checkbox" class="form-control sf" name="sf">
</div>
<div class="col-md-6 sfbox" style="display:none">
<input type="text" class="form-control sfboxval" readonly="">
</div> </div>
<div class="form-group">
<label class="col-md-4 control-label">25% Taxable Value</label>
<div class="col-md-1">
<input type="checkbox" class="form-control tf" name="tf">
</div>
<div class="col-md-6 tfbox" style="display:none" >
<input type="text" class="form-control tfboxval" readonly="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Tax in %</label>
<div class="col-md-7">
<input type="text" placeholder="" class="form-control tax" name="tax" value="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Grand Total</label>
<div class="col-md-7">
<input type="text" placeholder="" class="form-control grandtotal" readonly="" name="grand_total">
</div>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<legend>Particulars
<a class="btn btn-xs btn-success" id="apm"><i class="icon-plus"></i> Add new</a>
</legend>
<table id="apmr" width="69%" class="table table-striped table-bordered table-hover invoice">
<thead>
<tr>
<th width="3%">SL No</th>
<th width="25%">Description</th>
<th width="8%">Unit</th>
<th width="8%">Qty</th>
<th width="10%">Unit rate</th>
<th width="9%"> Amount</th>
</tr>
</thead>
<tbody class="roo">
<tr>
<td valign="center"> 1 </td>
<td class="tr_nt"><input type="text" name="parti[1][desc]" class="part"></td>
<td class="tr_nt"><input type="text" name="parti[1][unit]" class="part"></td>
<td class="tr_qty into"><input type="text" name="parti[1][qty]" class="part qty"></td>
<td class="tr_urate into"><input type="text" name="parti[1][urate]" class="part ur"></td>
<td class="tr_amt"><input type="text" name="parti[1][amount]" readonly="" class="part tot"></td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="4">
</td>
<td colspan="2">
Particular's Total: Rs <span class="parttotal"></span>
</td>
</tr>
</tfoot>
</table>
<p style="text-align: center;padding-top: 5px;"><input name="submit" class="btn-lg btn-primary" type="submit" value="View Invoice"></p>
</form> </div>
</div>
</div>
</div>
Javascript
//invoice particulars
var val;
$("#apm").click(function(event) {
//event.preventDefault();
//var preData = $("#apmr tr:last").html();
//console.log(preData);
//
//$("#apmr tr:last").after('<tr>' + preData + '</tr>');
var lasttd = $('.roo tr:last td:first').text();
val = parseInt(lasttd) + 1;
$(".roo tr:last").after(' <tr> <td valign="center"> ' + val + ' </td> <td class="tr_nt"><input type="text" name="parti[' + val + '][desc]" class="part"></td> <td class="tr_nt"><input type="text" name="parti[' + val + '][unit]" class="part"></td> <td class="tr_qty into"><input type="text" name="parti[' + val + '][qty]" class="part qty"></td> <td class="tr_urate into"><input type="text" name="parti[' + val + '][urate]" class="part ur"></td> <td class="tr_amt"><input type="text" name="parti[' + val + '][amount]" readonly class="part tot" ></td></tr>');
// val = val + 1;
return false;
})
var gt;
$("table.invoice").on("change", '.qty, .ur', function(event) {
calculateRow($(this).closest("tr"));
calculateTotal();
});
function calculateRow(row) {
var price = +row.find('.qty').val();
var qty = +row.find('.ur').val();
row.find('.tot').val((price * qty).toFixed(2));
}
function calculateTotal() {
var Total = 0;
$("table.invoice").find('.tot').each(function() {
Total += +$(this).val();
});
$(".parttotal").text(Total.toFixed(2));
calgrand();
}
$(".re-form").on('change', '.tax,.tf,.sf', function(event) {
calgrand();
})
function calgrand() {
var taxVal = $('.tax').val();
var parVal = $(".parttotal").text();
var result = parVal - taxVal * parVal / 100;
$('.grandtotal').val(result.toFixed(2));
if ($('.tf').is(':checked')) {
var resulttf = parVal - 25 * parVal / 100;
$('.tfboxval').val(resulttf.toFixed(2));
var result = result - resulttf;
$('.grandtotal').val(result.toFixed(2));
}
if ($('.sf').is(':checked')) {
//alert('entered');
var resultsf = parVal - 75 * parVal / 100;
$('.sfboxval').val(resultsf.toFixed(2));
var result = result - resultsf;
$('.grandtotal').val(result.toFixed(2));
}
}
$('.tf').click(function() {
$(".tfbox").toggle(this.checked);
});
$('.sf').click(function() {
$(".sfbox").toggle(this.checked);
});
in php i had
print_r($_POST['parti']);
its give out put
Array
(
[1] => Array
(
[desc] =>
[unit] =>
[qty] =>
[urate] =>
[amount] =>
)
)
but i need
Array
(
[1] => Array
(
[desc] =>
[unit] =>
[qty] =>
[urate] =>
[amount] =>
)
[2] => Array
(
[desc] =>
[unit] =>
[qty] =>
[urate] =>
[amount] =>
)
[3] => Array
(
[desc] =>
[unit] =>
[qty] =>
[urate] =>
[amount] =>
)
....
)
javascript
Please indent your code next time. Too many changes to make in your form. At the line where you have "Enter invoice no." you have left an open quote at value=""" which is a big mistake.
Overwrite your HTML code with this:
<div class="matter">
<div class="container">
<form method="POST" action="http://fabtech.com/invoices/create" accept-charset="UTF-8" role="form" class="form-horizontal re-form form-inv">
<input name="_token" type="hidden" value="aLngVzB1UIlY6cEedbAh55tirXGGkYJl78BL0CRN">
<div class="row">
<div class="col-md-12">
<legend>Invoice Details</legend>
<div class="col-md-6">
<div class="form-group">
<label class="col-md-4 control-label">Invoice No</label>
<div class="col-md-7">
<input type="text" placeholder="Enter invoice no" class="form-control" name="inv_no" value="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Invoice date</label>
<div class="col-md-7">
<input type="text" placeholder="Enter text" class="form-control date-pic" name="inv_date" value="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Customer</label>
<div class="col-md-7">
<select class="form-control" name="inv_customer">
<option value="">- Select Customer -</option>
<option value="suresh">suresh</option>
<option value="ABC210">ABC210</option>
<option value="QWERTy123DF">QWERTy123DF</option>
<option value="CUS002">CUS002</option>
<option value="CUS0023">CUS0023</option>
<option value="CUS003">CUS003</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">PO No</label>
<div class="col-md-7">
<input type="text" placeholder="Enter text" class="form-control" name="po_no" value="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">PO date</label>
<div class="col-md-7">
<input type="text" placeholder="DD/MM/YYY" class="form-control date-pic" name="po_date" value="">
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="col-md-4 control-label">Vendor code</label>
<div class="col-md-7">
<input type="text" placeholder="Enter Vendor Code" class="form-control" name="vendor_code" value="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">75% abatement value</label>
<div class="col-md-1">
<input type="checkbox" class="form-control sf" name="sf">
</div>
<div class="col-md-6 sfbox" style="display:none">
<input type="text" class="form-control sfboxval" readonly="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">25% Taxable Value</label>
<div class="col-md-1">
<input type="checkbox" class="form-control tf" name="tf">
</div>
<div class="col-md-6 tfbox" style="display:none">
<input type="text" class="form-control tfboxval" readonly="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Tax in %</label>
<div class="col-md-7">
<input type="text" placeholder="" class="form-control tax" name="tax" value="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Grand Total</label>
<div class="col-md-7">
<input type="text" placeholder="" class="form-control grandtotal" readonly="" name="grand_total">
</div>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<legend>Particulars <a class="btn btn-xs btn-success" id="apm"><i class="icon-plus"></i> Add new</a>
</legend>
<table id="apmr" width="69%" class="table table-striped table-bordered table-hover invoice">
<thead>
<tr>
<th width="3%">
SL No
</th>
<th width="25%">
Description
</th>
<th width="8%">
Unit
</th>
<th width="8%">
Qty
</th>
<th width="10%">
Unit rate
</th>
<th width="9%">
Amount
</th>
</tr>
</thead>
<tbody class="roo">
<tr>
<td valign="center">
1
</td>
<td class="tr_nt">
<input type="text" name="parti[1][desc]" class="part">
</td>
<td class="tr_nt">
<input type="text" name="parti[1][unit]" class="part">
</td>
<td class="tr_qty into">
<input type="text" name="parti[1][qty]" class="part qty">
</td>
<td class="tr_urate into">
<input type="text" name="parti[1][urate]" class="part ur">
</td>
<td class="tr_amt">
<input type="text" name="parti[1][amount]" readonly="" class="part tot">
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="4">
</td>
<td colspan="2">
Particular's Total: Rs <span class="parttotal"></span>
</td>
</tr>
</tfoot>
</table>
<p style="text-align: center;padding-top: 5px;">
<input name="submit" class="btn-lg btn-primary" type="submit" value="View Invoice">
</p>
</div>
</div>
</form>
</div>
</div>
Your mistake was that your <form> tag was closed in the wrong place. Remember to always place tags in such a way that always the inner tags close first.

Categories