Every Dropdown list have formopen codeigniter - codeigniter

i want to do is every dropdown list have submit example.
every list have formopen.
this is my sample code
<?php $delete = form_open('maintenance/delete',array('name'=>'deleteCheckForm'));
$active = form_open('maintenance/active',array('name'=>'deleteCheckForm'));
$disable = form_open('maintenance/disable',array('name'=>'deleteCheckForm'));
?>
<table>
<tr>
<?php foreach($sample as $list) { ?>
<td><input type="checkbox" name="type"></td>
<td>name :<?php echo $list->name; ?></td>
<?php } ?>
</tr>
</table>
<select onchange="this.form.submit()">
<option value="<?php echo $delete; ?>">delete</option>
<option value="<?php echo $active; ?>">active</option>
<option value="<?php echo $disable; ?>">disable</option>
</select>
<?php echo form_close(); ?>

<html>
<body>
<?php echo form_open('', array('name'=>'deleteCheckForm'))?>
<table>
<?php foreach($sample as $list) { ?>
<tr>
<td><input type="checkbox" name="type"></td>
<td>name :<?php echo $list->name; ?></td>
</tr>
<?php } ?>
</table>
<select onchange="this.form.action='<?php echo site_url('maintenance')?>/'+this.value;this.form.submit()">
<option value="delete">delete</option>
<option value="active">active</option>
<option value="disable">disable</option>
</select>
<?php echo form_close(); ?>
</body>
</html>

you can try this one
first make your form outside of php tag
<form action="your_action" id="delete_frm" method="post"></form>
<form action="your_action" id="active_frm" method="post"></form>
<form action="your_action" id="diable_frm" method="post"></form>
then your select option will be like
<select id="select_form_post">
<option value="delete">delete</option>
<option value="active">active</option>
<option value="disable">disable</option>
</select>
then your script will be like
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/ 1.7.1/ jquery.min.js"></script>
<script type="text/javascript">
$("#select_form_post").change(function(){
var form_to_post=$(this).val();
if(form_to_post=="delete")
{
$("#delete_frm").submit();
}
if(form_to_post=="active")
{
$("#active_frm").submit();
}
if(form_to_post=="disable")
{
$("#disable_frm").submit();
}
});
</script>
please let me know if you need anything more.

Related

How to set data-list option value in second text box using html & JS (onChange() )

I have 1 datalist containing food items Name & 2nd textbox to display price of selected food item . I'm not understanding how to make a function on datalist using js to onChange display price in textbox txtprice .
#I'm using codeigniter
<input list="browsers" id="browser" name="browser">
<datalist id="browsers" onchange="getComboA(this)">
<?php foreach($h as $row){ ?>
<option value="<?php echo $row->price;?>" >
<?php echo $row->menu_name;?>
</option>
<?php } ?>
</datalist>
<div class="col-12 col-md-2"><input type="text" placeholder="Price" class="form-control" id="txtPrice" name="txtPrice" value="<?php echo $row->price;?>" readonly >
</div>
eg : Item Name - Panner Tikka | Price - 150
It's quite easy actually, you could set it up like this :
<input list="browsers" id="browser" name="browser" onchange="setTxtPrice(this)">
<datalist id="browsers">
<?php foreach($h as $row){ ?>
<option value="<?php echo $row->price;?>" >
<?php echo $row->menu_name;?>
</option>
<?php } ?>
</datalist>
<div class="col-12 col-md-2">
<input type="text" placeholder="Price" class="form-control" id="txtPrice" name="txtPrice" value="<?php echo $row->price;?>" readonly >
</div>
<script type="text/javascript">
function setTxtPrice(input1) {
var input2 = document.getElementById('txtPrice');
input2.value = input1.value;
}
</script>
It is very easy to use onchange() in JS
Use this.value to get the value of datalist when option will change
<datalist id="browsers" onchange="PutValue(this.value)">
<?php foreach($h as $row){ ?>
<option value="<?php echo $row->price;?>" >
<?php echo $row->menu_name;?>
</option>
<?php } ?>
JS
function PutValue(Value){
$('#input_field_id').val(Value);
}

Codeigniter select box click get product details

Am creating a Billing System using Codeigniter. Here i want to select product using droupdown that product details show without refresh the page like ajax. My code is following:
View
<?php
foreach($productlists as $product)
{
?>
<tr>
<td>1</td>
<td>
<select class="form-control" name="product_id">
<option>--Select Payment--</option>
<option value="<?php echo $product['sno']; ?>"><?php echo $product['product_name']; ?></option>
</select>
</td>
<td><input type="number" name="product_order_qty" class="form-control" value="1"></td>
<td>0.8</td>
<td>0.8</td>
<td><input type="number" name="product_price" class="form-control" value="100"></td>
<td><input type="number" name="product_total" class="form-control" value="101.60"></td>
<td><a class="btn btn-primary waves-effect waves-light btn-xs"><i class="fa fa-plus"></i> Add</a></td>
</tr>
<?php } ?>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
//Ajax code here
</script>
And Pass the product id to controller
controller
function productdetails()
{
$id = $_GET['product_id'];
$data['product'] = $this->orders->productdetails($id);
$data['title'] = "View Customer Order";
$this->load->view('customer_order_view',$data);
}
Please help me to pass the product_id using Ajax.
Thanks in advance
<select class="form-control" name="product_id" onchange="getProduct(this.value)">
<option>--Select Payment--</option>
<option value="<?php echo $product['sno']; ?>"><?php echo $product['product_name']; ?></option>
</select>
//your jquery function
function getProduct(product_id){
alert(product_id);
$.ajax({
url: "your_url",
type: "POST",
data:
{
id:product_id,
}
}).done(function( data )
{
// alert(data);
});
}

how to get record into a dropdown list using both an input field value and another dropdown list value

i have 2 tables(login and subject table respectively). the input field has the session user's id (from login table) while the 1st drop down list holds all the classes assigned to him/her (from subject table). how can i collect all the subjects assigned to each classes into a 2nd drop down list still from the subject table using ajax if possible. Note:(Subject table has classes,subjects, staffid). below is my code:
<td class="header">TEACHER ID:</td>
<td>
<label>
<input type="text" name="staffid" class="input_txt" id="teachID" value="
<?php echo $staffDetails->staffID; ?>"></label>
</td>
<td class="header">CLASS:</td>
<td>
<select name="txtclassname" class="input_txt" id="class">
<option value="">-- Select Class --</option>
<?php
$staff = $staffDetails->staffID;
$stmt = $db->prepare("SELECT distinct className FROM subjects WHERE staffID = :sid");
$stmt->execute(array("sid"=>$staff));
while($row = $stmt->fetch(PDO::FETCH_ASSOC))
{
?>
<option value=""><?php echo $row['className']; ?></option>
<?php
}
?>
</select>
</td>
<td class="header">SUBJECTS:</td>
<td>
<!--I need all the subjects for a chosen class here-->
<select name="txtclassname" class="input_txt" id="class">
<option value="">--</option>
</select>
</td>
the modified javascript code:
<script type="text/javascript">
$(document).on('change', '#staffclass', function(){
if($(this).val() !==""){
$.ajax('get_staffSubjects.php?staffclass='+ $(this).val()).done(function(jsonOrHtml)){
var JSON = JSON.parse(jsonOrHtml);
var subjectSelect = $('#subject');
subjectSelect.html('<option value="">--Select Subject--</option>');
for(var i=0; i<json.length; i++){
subjectSelect.append('<option value="">'+json[i]+'</option>');
}
});
}
);
</script>
my server-side script (named:get_staffSubjects.php)
<?php
require_once 'myConn.php';
require_once 'session.php';
$db = getDB();
if(($_POST['staffclass']) & ($_POST['teachID']))
{
$staff = $_POST['teachID'];
$subs = $_POST['staffclass'];
$stmt = $db->prepare("SELECT * FROM subjects WHERE className=:staffclass AND staffID=:teachID");
$stmt->execute(array('id'=>$subs, 'teachID'=>$staff));
?>
<option value="">Select Subject:</option>
<?php
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
?>
<option value=""><?php echo $row['subName']; ?></option>
<?php
}
}
?>
Hi & welcome to stackoverflow. I'll just assume you know what to do on the server side to get the subjects, and show you how to use jquery to get them via ajax.
<td class="header">TEACHER ID:</td>
<td>
<label>
<input type="text" name="staffid" class="input_txt" id="teachID" value="<?php echo $staffDetails->staffID; ?>">
</label>
</td>
<td class="header">CLASS:</td>
<td>
<select name="txtclassname" class="input_txt" id="class">
<option value="">-- Select Class --</option>
<?php
$staff = $staffDetails->staffID;
$stmt = $db->prepare("SELECT distinct className FROM subjects WHERE staffID = :sid");
$stmt->execute(array("sid"=>$staff));
while($row = $stmt->fetch(PDO::FETCH_ASSOC))
{
?>
<option value=""><?php echo $row['className']; ?></option>
<?php
}
?>
</select>
</td>
<td class="header">SUBJECTS:</td>
<td>
<!--Notice that I've changed the name and id of this drop-down, as I expect you need those to be unique -->
<select name="txtsubject" class="input_txt" id="subject">
<option value="">--Select Subject--</option>
</select>
</td>
<script type="text/javascript">
//I'm using jquery, which is a quick solution
//NB: I don't like that the id='class', better use some other name
$(document).ready(function(){ // this ensure the code below happens after page is fully loaded
$(document).on('change', '#class', function(){
if($(this).val()!==""){
$.ajax('get_staffSubjects.php?staffclass='+ $(this).val()).done(function(html){
var subjectSelect = $('#subject');
//since html is constructed on the server side, we'll just append the response to the drop-down
subjectSelect.html(html);
});
}
});
});
</script>
Let me know if you have any questions.

Opencart can't load Region / State dropdown

I'm using opencart 1.5.5.1 with a theme (sancart) and I'm getting a very annoying bug.
In the modules checkout/cart and account/register the dropdown menu for Region/State field won't load the relative values (i guess are called zone or zone_id) and remains empty, blank.
The same function instead works well in the module checkout/checkout proceeding both as Guest or user registration.
Googleing around I've notice that is a pretty common bug with many themes, above all for those using SSH (that's not my case), but I couldn't find any real solution.
You can see my website at the URL http://i-tec.pro (ID: guest , PW: itec2013)
register.tpl
<?php echo $header; ?>
<?php if ($error_warning) { ?>
<div class="warning"><?php echo $error_warning; ?></div>
<?php } ?>
<?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content"><?php echo $content_top; ?>
<div class="breadcrumb">
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
<?php echo $breadcrumb['separator']; ?><?php echo $breadcrumb['text']; ?>
<?php } ?>
</div>
<h1><?php echo $heading_title; ?></h1><div class="padding20">
<p><?php echo $text_account_already; ?></p>
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
<h2><?php echo $text_your_details; ?></h2>
<div class="content">
<table class="form">
<tr>
<td><span class="required">*</span> <?php echo $entry_firstname; ?></td>
<td><input type="text" name="firstname" value="<?php echo $firstname; ?>" />
<?php if ($error_firstname) { ?>
<span class="error"><?php echo $error_firstname; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_lastname; ?></td>
<td><input type="text" name="lastname" value="<?php echo $lastname; ?>" />
<?php if ($error_lastname) { ?>
<span class="error"><?php echo $error_lastname; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_email; ?></td>
<td><input type="text" name="email" value="<?php echo $email; ?>" />
<?php if ($error_email) { ?>
<span class="error"><?php echo $error_email; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_telephone; ?></td>
<td><input type="text" name="telephone" value="<?php echo $telephone; ?>" />
<?php if ($error_telephone) { ?>
<span class="error"><?php echo $error_telephone; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><?php echo $entry_fax; ?></td>
<td><input type="text" name="fax" value="<?php echo $fax; ?>" /></td>
</tr>
</table>
</div>
<h2><?php echo $text_your_address; ?> </h2>
<div class="content">
<table class="form">
<tr>
<td><?php echo $entry_company; ?></td>
<td><input type="text" name="company" value="<?php echo $company; ?>" /></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_address_1; ?></td>
<td><input type="text" name="address_1" value="<?php echo $address_1; ?>" />
<?php if ($error_address_1) { ?>
<span class="error"><?php echo $error_address_1; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><?php echo $entry_address_2; ?></td>
<td><input type="text" name="address_2" value="<?php echo $address_2; ?>" /></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_city; ?></td>
<td><input type="text" name="city" value="<?php echo $city; ?>" />
<?php if ($error_city) { ?>
<span class="error"><?php echo $error_city; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_postcode; ?></td>
<td><input type="text" name="postcode" value="<?php echo $postcode; ?>" />
<?php if ($error_postcode) { ?>
<span class="error"><?php echo $error_postcode; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_country; ?></td>
<td><select name="country_id" onchange="$('select[name=\'zone_id\']').load('index.php?route=account/register/zone&country_id=' + this.value + '&zone_id=<?php echo $zone_id; ?>');">
<option value=""><?php echo $text_select; ?></option>
<?php foreach ($countries as $country) { ?>
<?php if ($country['country_id'] == $country_id) { ?>
<option value="<?php echo $country['country_id']; ?>" selected="selected"><?php echo $country['name']; ?></option>
<?php } else { ?>
<option value="<?php echo $country['country_id']; ?>"><?php echo $country['name']; ?></option>
<?php } ?>
<?php } ?>
</select>
<?php if ($error_country) { ?>
<span class="error"><?php echo $error_country; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_zone; ?></td>
<td><select name="zone_id">
</select>
<?php if ($error_zone) { ?>
<span class="error"><?php echo $error_zone; ?></span>
<?php } ?></td>
</tr>
</table>
</div>
<h2><?php echo $text_your_password; ?></h2>
<div class="content">
<table class="form">
<tr>
<td><span class="required">*</span> <?php echo $entry_password; ?></td>
<td><input type="password" name="password" value="<?php echo $password; ?>" />
<?php if ($error_password) { ?>
<span class="error"><?php echo $error_password; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_confirm; ?></td>
<td><input type="password" name="confirm" value="<?php echo $confirm; ?>" />
<?php if ($error_confirm) { ?>
<span class="error"><?php echo $error_confirm; ?></span>
<?php } ?></td>
</tr>
</table>
</div>
<h2><?php echo $text_newsletter; ?></h2>
<div class="content">
<table class="form">
<tr>
<td><?php echo $entry_newsletter; ?></td>
<td><?php if ($newsletter == 1) { ?>
<input type="radio" name="newsletter" value="1" checked="checked" />
<?php echo $text_yes; ?>
<input type="radio" name="newsletter" value="0" />
<?php echo $text_no; ?>
<?php } else { ?>
<input type="radio" name="newsletter" value="1" />
<?php echo $text_yes; ?>
<input type="radio" name="newsletter" value="0" checked="checked" />
<?php echo $text_no; ?>
<?php } ?></td>
</tr>
</table>
</div>
<?php if ($text_agree) { ?>
<div class="buttons">
<div class="right"><?php echo $text_agree; ?>
<?php if ($agree) { ?>
<input type="checkbox" name="agree" value="1" checked="checked" />
<?php } else { ?>
<input type="checkbox" name="agree" value="1" />
<?php } ?>
<input type="submit" value="<?php echo $button_continue; ?>" class="button" />
</div>
</div>
<?php } else { ?>
<div class="buttons">
<div class="right">
<input type="submit" value="<?php echo $button_continue; ?>" class="button" />
</div>
</div>
<?php } ?>
</form></div>
<?php echo $content_bottom; ?></div>
<script type="text/javascript"><!--
$('select[name=\'zone_id\']').load('index.php?route=account/register/zone&country_id=<?php echo $country_id; ?>&zone_id=<?php echo $zone_id; ?>');
//--></script>
<script type="text/javascript"><!--
$('.colorbox').colorbox({
width: 560,
height: 560
});
//--></script>
<?php echo $footer; ?>
cart.tpl
<?php echo $header; ?>
<?php if ($attention) { ?>
<div class="attention"><?php echo $attention; ?><img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>
<?php } ?>
<?php if ($success) { ?>
<div class="success"><?php echo $success; ?><img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>
<?php } ?>
<?php if ($error_warning) { ?>
<div class="warning"><?php echo $error_warning; ?><img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>
<?php } ?>
<?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content"><?php echo $content_top; ?>
<div class="breadcrumb">
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
<?php echo $breadcrumb['separator']; ?><?php echo $breadcrumb['text']; ?>
<?php } ?>
</div>
<h1><?php echo $heading_title; ?><div class="padding20">
<?php if ($weight) { ?>
(<?php echo $weight; ?>)
<?php } ?>
</h1>
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
<div class="cart-info">
<table>
<thead>
<tr>
<td class="image"><?php echo $column_image; ?></td>
<td class="name"><?php echo $column_name; ?></td>
<td class="model"><?php echo $column_model; ?></td>
<td class="quantity"><?php echo $column_quantity; ?></td>
<td class="price"><?php echo $column_price; ?></td>
<td class="total"><?php echo $column_total; ?></td>
</tr>
</thead>
<tbody>
<?php foreach ($products as $product) { ?>
<tr>
<td class="image"><?php if ($product['thumb']) { ?>
<img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" />
<?php } ?></td>
<td class="name"><?php echo $product['name']; ?>
<?php if (!$product['stock']) { ?>
<span class="stock">***</span>
<?php } ?>
<div>
<?php foreach ($product['option'] as $option) { ?>
- <small><?php echo $option['name']; ?>: <?php echo $option['value']; ?></small><br />
<?php } ?>
</div>
<?php if ($product['reward']) { ?>
<small><?php echo $product['reward']; ?></small>
<?php } ?></td>
<td class="model"><?php echo $product['model']; ?></td>
<td class="quantity"><input type="text" name="quantity[<?php echo $product['key']; ?>]" value="<?php echo $product['quantity']; ?>" size="1" />
<input type="image" src="catalog/view/theme/default/image/update.png" alt="<?php echo $button_update; ?>" title="<?php echo $button_update; ?>" />
<img src="catalog/view/theme/default/image/remove.png" alt="<?php echo $button_remove; ?>" title="<?php echo $button_remove; ?>" /></td>
<td class="price"><?php echo $product['price']; ?></td>
<td class="total"><?php echo $product['total']; ?></td>
</tr>
<?php } ?>
<?php foreach ($vouchers as $vouchers) { ?>
<tr>
<td class="image"></td>
<td class="name"><?php echo $vouchers['description']; ?></td>
<td class="model"></td>
<td class="quantity"><input type="text" name="" value="1" size="1" disabled="disabled" />
<img src="catalog/view/theme/default/image/remove.png" alt="<?php echo $text_remove; ?>" title="<?php echo $button_remove; ?>" /></td>
<td class="price"><?php echo $vouchers['amount']; ?></td>
<td class="total"><?php echo $vouchers['amount']; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</form>
<?php if ($coupon_status || $voucher_status || $reward_status || $shipping_status) { ?>
<h2><?php echo $text_next; ?></h2>
<div class="content">
<p><?php echo $text_next_choice; ?></p>
<table class="radio">
<?php if ($coupon_status) { ?>
<tr class="highlight">
<td><input type="radio" name="next" value="coupon" id="use_coupon" /></td>
<td><label for="use_coupon"><?php echo $text_use_coupon; ?></label></td>
</tr>
<?php } ?>
<?php if ($voucher_status) { ?>
<tr class="highlight">
<td><input type="radio" name="next" value="voucher" id="use_voucher" /></td>
<td><label for="use_voucher"><?php echo $text_use_voucher; ?></label></td>
</tr>
<?php } ?>
<?php if ($reward_status) { ?>
<tr class="highlight">
<td><input type="radio" name="next" value="reward" id="use_reward" /></td>
<td><label for="use_reward"><?php echo $text_use_reward; ?></label></td>
</tr>
<?php } ?>
<?php if ($shipping_status) { ?>
<tr class="highlight">
<td><input type="radio" name="next" value="shipping" id="shipping_estimate" /></td>
<td><label for="shipping_estimate"><?php echo $text_shipping_estimate; ?></label></td>
</tr>
<?php } ?>
</table>
</div>
<div class="cart-module">
<div id="coupon" class="content">
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
<?php echo $entry_coupon; ?>
<input type="text" name="coupon" value="<?php echo $coupon; ?>" />
<input type="hidden" name="next" value="coupon" />
<input type="submit" value="<?php echo $button_coupon; ?>" class="button" />
</form>
</div>
<div id="voucher" class="content">
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
<?php echo $entry_voucher; ?>
<input type="text" name="voucher" value="<?php echo $voucher; ?>" />
<input type="hidden" name="next" value="voucher" />
<input type="submit" value="<?php echo $button_voucher; ?>" class="button" />
</form>
</div>
<div id="reward" class="content">
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
<?php echo $entry_reward; ?>
<input type="text" name="reward" value="<?php echo $reward; ?>" />
<input type="hidden" name="next" value="reward" />
<input type="submit" value="<?php echo $button_reward; ?>" class="button" />
</form>
</div>
<div id="shipping" class="content">
<p><?php echo $text_shipping_detail; ?></p>
<table>
<tr>
<td><span class="required">*</span> <?php echo $entry_country; ?></td>
<td><select name="country_id" onchange="$('select[name=\'zone_id\']').load('index.php?route=checkout/cart/zone&country_id=' + this.value + '&zone_id=<?php echo $zone_id; ?>');">
<option value=""><?php echo $text_select; ?></option>
<?php foreach ($countries as $country) { ?>
<?php if ($country['country_id'] == $country_id) { ?>
<option value="<?php echo $country['country_id']; ?>" selected="selected"><?php echo $country['name']; ?></option>
<?php } else { ?>
<option value="<?php echo $country['country_id']; ?>"><?php echo $country['name']; ?></option>
<?php } ?>
<?php } ?>
</select></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_zone; ?></td>
<td><select name="zone_id">
</select></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_postcode; ?></td>
<td><input type="text" name="postcode" value="<?php echo $postcode; ?>" /></td>
</tr>
</table>
<input type="button" value="<?php echo $button_quote; ?>" id="button-quote" class="button" />
</div>
<?php } ?>
</div>
<div class="cart-total">
<table id="total">
<?php foreach ($totals as $total) { ?>
<tr>
<td colspan="5" class="right"><b><?php echo $total['title']; ?>:</b></td>
<td class="right"><?php echo $total['text']; ?></td>
</tr>
<?php } ?>
</table>
</div>
<div class="buttons">
<div class="right"><?php echo $button_checkout; ?></div>
<div class="center"><?php echo $button_shopping; ?></div>
</div></div>
<?php echo $content_bottom; ?></div>
<script type="text/javascript"><!--
$('input[name=\'next\']').bind('change', function() {
$('.cart-module > div').hide();
$('#' + this.value).show();
});
<?php if ($next == 'coupon') { ?>
$('#use_coupon').trigger('click');
<?php } ?>
<?php if ($next == 'voucher') { ?>
$('#use_voucher').trigger('click');
<?php } ?>
<?php if ($next == 'reward') { ?>
$('#use_reward').trigger('click');
<?php } ?>
<?php if ($next == 'shipping') { ?>
$('#shipping_estimate').trigger('click');
<?php } ?>
//--></script>
<?php if ($shipping_status) { ?>
<script type="text/javascript"><!--
$('#button-quote').live('click', function() {
$.ajax({
url: 'index.php?route=checkout/cart/quote',
type: 'post',
data: 'country_id=' + $('select[name=\'country_id\']').val() + '&zone_id=' + $('select[name=\'zone_id\']').val() + '&postcode=' + encodeURIComponent($('input[name=\'postcode\']').val()),
dataType: 'json',
beforeSend: function() {
$('#button-quote').attr('disabled', true);
$('#button-quote').after('<span class="wait"> <img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
},
complete: function() {
$('#button-quote').attr('disabled', false);
$('.wait').remove();
},
success: function(json) {
$('.success, .warning, .attention, .error').remove();
if (json['error']) {
if (json['error']['warning']) {
$('#notification').html('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
$('.warning').fadeIn('slow');
$('html, body').animate({ scrollTop: 0 }, 'slow');
}
if (json['error']['country']) {
$('select[name=\'country_id\']').after('<span class="error">' + json['error']['country'] + '</span>');
}
if (json['error']['zone']) {
$('select[name=\'zone_id\']').after('<span class="error">' + json['error']['zone'] + '</span>');
}
if (json['error']['postcode']) {
$('input[name=\'postcode\']').after('<span class="error">' + json['error']['postcode'] + '</span>');
}
}
if (json['shipping_method']) {
html = '<h2><?php echo $text_shipping_method; ?></h2>';
html += '<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">';
html += ' <table class="radio">';
for (i in json['shipping_method']) {
html += '<tr>';
html += ' <td colspan="3"><b>' + json['shipping_method'][i]['title'] + '</b></td>';
html += '</tr>';
if (!json['shipping_method'][i]['error']) {
for (j in json['shipping_method'][i]['quote']) {
html += '<tr class="highlight">';
if (json['shipping_method'][i]['quote'][j]['code'] == '<?php echo $shipping_method; ?>') {
html += '<td><input type="radio" name="shipping_method" value="' + json['shipping_method'][i]['quote'][j]['code'] + '" id="' + json['shipping_method'][i]['quote'][j]['code'] + '" checked="checked" /></td>';
} else {
html += '<td><input type="radio" name="shipping_method" value="' + json['shipping_method'][i]['quote'][j]['code'] + '" id="' + json['shipping_method'][i]['quote'][j]['code'] + '" /></td>';
}
html += ' <td><label for="' + json['shipping_method'][i]['quote'][j]['code'] + '">' + json['shipping_method'][i]['quote'][j]['title'] + '</label></td>';
html += ' <td style="text-align: right;"><label for="' + json['shipping_method'][i]['quote'][j]['code'] + '">' + json['shipping_method'][i]['quote'][j]['text'] + '</label></td>';
html += '</tr>';
}
} else {
html += '<tr>';
html += ' <td colspan="3"><div class="error">' + json['shipping_method'][i]['error'] + '</div></td>';
html += '</tr>';
}
}
html += ' </table>';
html += ' <br />';
html += ' <input type="hidden" name="next" value="shipping" />';
html += ' <input type="submit" value="<?php echo $button_shipping; ?>" class="button" />';
html += '</form>';
$.colorbox({
overlayClose: true,
opacity: 0.5,
width: '600px',
height: '400px',
href: false,
html: html
});
}
}
});
});
//--></script>
<script type="text/javascript"><!--
$('select[name=\'zone_id\']').load('index.php?route=checkout/cart/zone&country_id=<?php echo $country_id; ?>&zone_id=<?php echo $zone_id; ?>');
//--></script>
<?php } ?>
<?php echo $footer; ?>
Thank you in advance!
The problem is in the URL it is trying to load:
http://www.i-tec.pro/index.php?route=account/register/zone&country_id=30
In the controller catalog/controller/account/register.php there is no such an action called zone - therefore the server returns a 404 response and no zones are loaded.
This action is not present in that controller at least from version 1.5.3 (have no access to older versions right now, will check that later) - but You are using the latest OC version.
Probably the theme is not compatible with newer versions of OC - check that with the theme creators...
EDIT: Should You wish to repair the template for Yourself, add this JavaScript code at the end of the register.tpl
$('select[name=\'country_id\']').bind('change', function() {
$.ajax({
url: 'index.php?route=account/register/country&country_id=' + this.value,
dataType: 'json',
beforeSend: function() {
$('select[name=\'country_id\']').after('<span class="wait"> <img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
},
complete: function() {
$('.wait').remove();
},
success: function(json) {
if (json['postcode_required'] == '1') {
$('#postcode-required').show();
} else {
$('#postcode-required').hide();
}
html = '<option value=""><?php echo $text_select; ?></option>';
if (json['zone'] != '') {
for (i = 0; i < json['zone'].length; i++) {
html += '<option value="' + json['zone'][i]['zone_id'] + '"';
if (json['zone'][i]['zone_id'] == '<?php echo $zone_id; ?>') {
html += ' selected="selected"';
}
html += '>' + json['zone'][i]['name'] + '</option>';
}
} else {
html += '<option value="0" selected="selected"><?php echo $text_none; ?></option>';
}
$('select[name=\'zone_id\']').html(html);
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
$('select[name=\'country_id\']').trigger('change');
and remove any previous $('select[\'name=country_id\']').change(...); calls.
change the javascript code from catalog/view/theme/YOUR THEME/template/account/register.tpl to this code here
<script type="text/javascript"><!--
$('select[name=\'country_id\']').bind('change', function() {
$.ajax({
url: 'index.php?route=account/register/country&country_id=' + this.value,
dataType: 'json',
beforeSend: function() {
$('select[name=\'country_id\']').after('<span class="wait"> <img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
},
complete: function() {
$('.wait').remove();
},
success: function(json) {
if (json['postcode_required'] == '1') {
$('#postcode-required').show();
} else {
$('#postcode-required').hide();
}
html = '<option value=""><?php echo $text_select; ?></option>';
if (json['zone'] != '') {
for (i = 0; i < json['zone'].length; i++) {
html += '<option value="' + json['zone'][i]['zone_id'] + '"';
if (json['zone'][i]['zone_id'] == '<?php echo $zone_id; ?>') {
html += ' selected="selected"';
}
html += '>' + json['zone'][i]['name'] + '</option>';
}
} else {
html += '<option value="0" selected="selected"><?php echo $text_none; ?></option>';
}
$('select[name=\'zone_id\']').html(html);
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
$('select[name=\'country_id\']').trigger('change');
//--></script>

Fetch the entered quantity box values from multiple quantity box to cart page in magento

I am new to Magento.
I am displaying the attributes in table format using foreach in product detail page.
Problem i am facing is when i enter the value in any quantity box, it takes the last quantity value to the cart page since i am using foreach loop to display the quantity box.I need to display the exact value which i have entered in the quantity box.
Code:
<table border="1" style="width:100%;">
<thead>
<tr>
<th>Fabric</th>
<th>Color</th>
<th>Required Qty</th>
<th>Total Cost</th>
<th>Cart</th>
</tr>
</thead>
<?php
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'fabric');
$buttonTitle = $this->__('Add to Cart');
$i=0;foreach ( $attribute->getSource()->getAllOptions(true, true) as $option){
$i++;
if($i==1) continue;
?>
<tbody>
<tr>
<td>
<?php echo $attributeArray[$option['value']] = $option['label'];
?>
</td>
<td>
<select name="color" id="color">
<option>Select Color</option>
<?php
$color = Mage::getModel('eav/config')->getAttribute('catalog_product', 'fabric_color');
$j=0;foreach ( $color->getSource()->getAllOptions(true, true) as $option_color){
$j++;
if($j==1) continue;?>
<option value="<?php echo $option_color['value'];?>" price="<?php echo $option_color['price'];?>"><?php echo $option_color['label'];?></option>
<? }
?>
</select>
</td>
<td>
<?php if($_product->isSaleable()): ?>
<div class="add-to-cart">
<?php if(!$_product->isGrouped()): ?>
<label for="qty"><?php echo $this->__('Qty:') ?></label>
<div class="qty_pan">
<input type="text" name="qty" id="qty<?=$i;?>" maxlength="12" value="1" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</td>
<td ><span class="qty<?=$i;?>" id=""><?php echo $_product->getPrice();?></span></td>
<td>
<button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>
<!-- <span id='ajax_loader' style='display:none'><img src='<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif')?>'/></span>-->
<?php //echo $this->getChildHtml('', true, true) ?>
</td>
</tr>
</tbody>
<?php }?>
</table>
Screenshot:
https://imageshack.us/scaled/large/12/detailpage.png
Any help is appreciated!.
I Got The solution.
We can use Query String to fetch the quantity values to cart.
Yourdomain.com/checkout/cart/add?product=getId();?>&qty=1
You can use the above querystring in href.
Hope this Helps.

Resources