I have an order form with data. on submit the controller function new_blank_order_summary is called.
the syntax for this is:
function new_blank_order_summary()
{
echo "orderlines: ".$this->input->post(orderlines);
echo "customer: ".$this->input->post('customer');
echo "period: ".$this->input->post('period');
echo "creditlimit: ".$this->input->post('creditlimit');
$this->load->view('sales/new_blank_order_summary');
}
I cannot get the post information to display or echo? my input Name and ID is orderlines but this is not being posted or received properly.
Apologies for the 'stupid' question.
any advice welcome.
HTML
<form id="sales_blank_order_details" action="/sales/new_blank_order_summary" method="post">
<table >
<tr><td>Customer</td><td>Period</td><td>UoM</td><td>Credit Limit</td><td>Balance</td><td>New Balance</td><td>Order Lines</td><td>Round to Bundle</td></tr>
<tr><td>
<input type="text" name="customer" id="customer" value="<?php echo $customer; ?>" disabled>
</td><td>
<input type="text" name="period" id="period" value="<?php echo $period." to ".$newperiod; ?>" disabled>
</td><td>
<input type="text" name="buom" id="buom" value="<?php echo $buom; ?>" disabled>
</td><td>
<input type="text" name="creditlimit" id="creditlimit" value="<?php echo $creditlimit['creditlimit']; ?>" disabled>
</td><td>
<input type="text" name="currentbalance" id="currentbalance" value="<?php echo $creditlimit['currentbalance']; ?>" disabled>
</td>
<td>
<input type="text" name="newbalance" id="newbalance" value="<?php echo $creditlimit['currentbalance']; ?>" disabled>
</td><td>
<input type="text" name="orderlines" id="orderlines" value="1" disabled>
</td><td>
<input type="checkbox" name="rounduptobundle" id="rounduptobundle" checked>
</td></tr></table>
<input type="submit" name="blank_order_lines" id="blank_order_lines" value="Save Order and Proceed">
</form>
None of these posts are outputted by controller.
You've disabled the orderlines text input field so that's why it will not get posted. Remove disabledand it will show up in $this->input->post().
what is the name and value of your submit button. Usually the name of my submit button is name="submit" and the value is value="submit". So then I try $this->input->post('submit')=='submit'. try this in your if condition. I hope it will work. best of luck.
function new_blank_order_summary()
{
echo "orlderlines: ".$this->input->post('orderlines');
echo "customer: ".$this->input->post('customer');
echo "period: ".$this->input->post('period');
echo "creditlimit: ".$this->input->post('creditlimit');
$this->load->view('sales/new_blank_order_summary');
}
Please try this code. I didn't change a single line in it. Only I put the single quotes in the 3rd line. And, changed it's variable name is wrong so I changed it
Related
Guys I am stuck here in Codeigniter validation. The scenario is that I want to display all the error messages right below each respective input field and not all the error messages together on the top of the form. Could anyone help me, how to do this?
Check below mentioned code. This will help you.
<h5>Username</h5>
<?php echo form_error('username'); ?>
<input type="text" name="username" value="<?php echo set_value('username'); ?>" size="50" />
<h5>Password</h5>
<?php echo form_error('password'); ?>
<input type="text" name="password" value="<?php echo set_value('password'); ?>" size="50" />
<h5>Password Confirm</h5>
<?php echo form_error('passconf'); ?>
<input type="text" name="passconf" value="<?php echo set_value('passconf'); ?>" size="50" />
<h5>Email Address</h5>
<?php echo form_error('email'); ?>
<input type="text" name="email" value="<?php echo set_value('email'); ?>" size="50" />
Use form_error() function to do that. As describe in manual
echo form_error('username');
All you have to do is put this line under the field where you want to see error message. Here username is the name of the form field
more details
https://www.codeigniter.com/user_guide/libraries/form_validation.html#showing-errors-individually
write below code after your text or drop-down field
<?php echo form_error('field_name','<div class="errorClass">','</div>');?>
I want to have my date field remember my old input
Is there any way i can do this?
Here's my code
<div class="form-group">
<label for="date1">Date From: </label>
<input id="date1" name="date1" type="date" value="<?php echo date('Y-m-d'); ?>" class="form-control">
</div>
<div class="form-group">
<label for="date2">Date To: </label>
<input id="date2" name="date2" type="date" value="<?php echo date('Y-m-d'); ?>" class="form-control">
</div>
Please Help. Thank You!
If you want to have a default but also remember the user provided input in case of any error you could do something like this:
<input type="date" name="date2" value="{{ old('date2', date('Y-m-d')) }}">
Then in your controller when you redirect back make sure to call the ->withInput()method.
First you need to redirect from your controller "With inputs" something like this:
return redirect('some/form/route')->withInput();
Then in your template:
Request::old('date_field')
Or in a blade template:
{{ old('date_field') }}
More detail in the "Old Input" section in L5 docs
Hi i have this select checkbox which is weekdays the checkboxes were sunday monday tuesday wednesday thursday friday saturday. Users can able to choose as many as they want. And i save the data to my database,like for example users choose sunday monday tuesday, i save that into my fields as 1-2-3 with only one field name available_days_per_week. Now my problem is when i queried the data and display into my edit page i want that only 1-2-3 will be checked. What happened is the data doubles. My code works but displays into double. Heres my code below
<tr>
<th>Available days per week</th>
<td>
<?php $daysPerWeeks = $query->available_days_per_week; ?>
<?php $daysPerWeeks1 = explode("-", $daysPerWeeks); ?>
<?php foreach($daysPerWeeks1 as $value): ?>
<?php foreach($daysPerWeekCheckboxes as $key=>$week): ?>
<input type="checkbox" name="available_days_week" value="<?php echo $key ?>" <?php echo($value == $key) ? 'checked="checked"' : ''?> ><?php echo $week; ?><br>
<?php endforeach; ?>
<?php endforeach; ?>
</td>
</tr>
that will display into my page like this
<tr>
<th>Available days per week</th>
<td>
<input type="checkbox" name="available_days_week" value="1" checked="checked" >Sunday<br>
<input type="checkbox" name="available_days_week" value="2" >Monday<br>
<input type="checkbox" name="available_days_week" value="3" >Tuesday<br>
<input type="checkbox" name="available_days_week" value="4" >Wendesday<br>
<input type="checkbox" name="available_days_week" value="5" >Thursday<br>
<input type="checkbox" name="available_days_week" value="6" >Friday<br>
<input type="checkbox" name="available_days_week" value="7" >Saturday<br>
<input type="checkbox" name="available_days_week" value="1" >Sunday<br>
<input type="checkbox" name="available_days_week" value="2" checked="checked" >Monday<br>
<input type="checkbox" name="available_days_week" value="3" >Tuesday<br>
<input type="checkbox" name="available_days_week" value="4" >Wendesday<br>
<input type="checkbox" name="available_days_week" value="5" >Thursday<br>
<input type="checkbox" name="available_days_week" value="6" >Friday<br>
<input type="checkbox" name="available_days_week" value="7" >Saturday<br>
<input type="checkbox" name="available_days_week" value="1" >Sunday<br>
<input type="checkbox" name="available_days_week" value="2" >Monday<br>
<input type="checkbox" name="available_days_week" value="3" checked="checked" >Tuesday<br>
<input type="checkbox" name="available_days_week" value="4" >Wendesday<br>
<input type="checkbox" name="available_days_week" value="5" >Thursday<br>
<input type="checkbox" name="available_days_week" value="6" >Friday<br>
<input type="checkbox" name="available_days_week" value="7" >Saturday<br>
</td>
</tr>
as youve noticed it wil double
heres my static code that will return days of weeks
//return days per week checkbox
public static function getDaysPerWeekCheckbox(){
return array(
1 =>'Sunday',
2 =>'Monday',
3 =>'Tuesday',
4 =>'Wendesday',
5 =>'Thursday',
6 =>'Friday',
7 =>'Saturday'
);
}
How can i avoid the data that will not doubled when displaying in the edit page?.
Can someone help me figured this thing out?.Any help is muchly appreciated.
You are looping unnecessarily. Try this:
<?php $days = getDaysPerWeekCheckbox(); ?>
<?php foreach($days as $index => $day_name): ?>
<input type="checkbox" name="available_days_week" value="<?php echo $index ?>" <?php echo(in_array($index, $daysPerWeeks1)) ? 'checked="checked"' : ''?> ><?php echo $day_name; ?><br>
<?php endforeach; ?>
i have this form that submits personal details
here is my view
<?php $attributes=a rray( 'autocomplete'=>"off", 'id' => 'theForm');?>
<?php echo form_open_multipart( 'employee/personaldetails', $attributes); ?>
<div class="row">
<div class="span3 offset1">
<label>First Name</label>
<input onkeypress="return fnAllowAlpha(event);" maxlength="50" type="text" value="<?php echo $info['first_name']; ?>" name="first_name" disabled>
<input type="hidden" value="<?php echo $info['employee_image']; ?>" name="employee_image" disabled>
</div>
<div class="span3">
<label>Middle Name</label>
<input onkeypress="return fnAllowAlpha(event);" maxlength="50" type="text" value="<?php echo $info['middle_name']; ?>" name="middle_name" disabled>
</div>
<div class="span3">
<label>Last Name</label>
<input onkeypress="return fnAllowAlpha(event);" maxlength="50" type="text" value="<?php echo $info['last_name']; ?>" name="last_name" disabled>
</div>
<div class="span1">
<div class="down1">
<button type="submit" class="button-orange" id="btnSave" style="display:none;">Save</button>
</div>
</div>
CONTROLLER
$this->load->model('mdl_employee','emp');
$id = $this->session->userdata('id');
$P1 = $this->input->post('first_name');
$P2 = $this->input->post('middle_name');
$P3 = $this->input->post('last_name');
$this->emp->update_myinfo($id, $P1, $P2, $P3);
model
public function update_myinfo($id, $P1, $P2, $P3){
$employee_data = array(
'first_name' => $P1,
'middle_name' => $P2,
'last_name' => $P3);
$this->db->where('employee_id', $id);
$this->db->update('employee', $employee_data);
}
i dont know how to use ajax.
i want to alert the ajax if success or not. after updating my database.. im just new programmer
Maybe you could try googling since its so common to submit forms using ajax.
http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/
Submitting HTML form using Jquery AJAX
I would suggest first try these links..and if u still get stuck then let us know, we would surely help you :)
i have error for submitting form using javascript. the error said unknown column array. what is wrong with my array or maybe on my javascript.
this is my sample code.
<form action="">
<input type="text" name="name">
<input type="text" name="age">
<input type="button"onClick="this.form.action='<?php echo site_url('core')?>/'+'add_name';this.form.submit();" value="new"/>
</form>
WORKING WITHOUT JS
Try this:
<?php
$frmAttrs = array("id"=>"addFrm");
echo form_open('core/add_name', $frmAttrs);
?>
<input type="text" name="name">
<input type="text" name="age">
<!-- <input type="button" onClick="this.form.action='<?php //echo site_url('core/')?>'+'add_name';this.form.submit();" value="new"/> -->
<input type="button" id="submitFrm" onClick="this.form.submit();" value="new" />
</form>