Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
working on restaurant webiste. and i wanted to give choice for the food item to the customer as they can modify their catering order,i have use jquery to pass choice value to catering order form by hidden field. but that value doesn't displayed on catering order form! how to pass value from jquery to php ?

What I have tried:

HTML
<!-- choice -->
					<div class="label_input_group">
						<!--<div class="col-md-3">-->
						<label class="pull-left row hidden"><?php echo $lang['cp_order_choice']; ???></label>
						
						<input type="text" class="hidden col-md-3  list_of_choice form-control" id="order_choice" name="order_choice" value="aaa"/>
						<!--<div class="menuitemids goeshere row">-->
								<div class="cart_choice_goes_up"></div>
					 <!-- </div>-->
						<!--</div>-->
					</div>
					<!-- size -->
						<div class="label_input_group">
						<!--<div class="col-md-2">-->
							<label class="pull-left row hidden"><?php echo $lang['cp_order_size']; ???></label>
							<input  type="text" class="hidden col-md-2 list_of_size form-control" id="order_size" name="order_size" value=""/>
							<div class="cart_size_goes_up"></div>
						<!--</div>-->
					</div>

php

<div class="move_menu_item_inputs">
					
					<input class=" choice" type="hidden" name="menu_item_choice" value="<?php echo $result3['menu_item_choice']; ???>"/>
						<input class=" size" type="hidden" name="menu_item_size" value="<?php echo $result3['menu_item_size']; ???>"/>
						<input class="single_menu_item" type="hidden" name="menu_item_id[]" value="<?php echo $result3['menu_item_id']; ???>" />
						
						<input disabled="disabled" class="single_menu_item menu_item_price_per_slice" type="hidden" name="menu_item_price_per_slice[]" value="<?php echo $result3['menu_item_price_per_slice']; ???>" />
						<input class="single_menu_item item_name col-md-8 form-control" readonly="readonly"  type="text" name="menu_item_name[]" value="<?php echo $result3['menu_item_name']; ???>" />
						<input class="single_menu_item temporary_price_foreach_product" type="hidden" value="" />
						<button aria-hidden="true" class="form-control remove-product-from-cart single_menu_item" type="button">×</button>

						<div class="single_menu_item col-md-2">
						    <input type="text" value="1" class="pull-left row plus-minus-qty form-control" name="plus_minus_qty[]" />
						</div>
					</div>
JS\
	 var choicetotal = '';
    jQuery('.cart_choice_goes_up .choice').each(function(){ //count total choice in cart
        choicetotal += jQuery(this).val();
		 //jQuery('input.list_of_choice').val( choicetotal );
		 
    });
	
	jQuery('input.list_of_choice').html(choicetotal); //place item  choice value
	 console.log("choice :- "+choicetotal);
	 
	var sizetotal = '';
    jQuery('.cart_size_goes_up .size').each(function(){ //count total size in cart
        sizetotal += jQuery(this).val();
		 //jQuery('input.list_of_size').val( sizetotal );
		<!--$('#order_size').val("sizetotal");-->
    });
	
jQuery('input.list_of_size').html(sizetotal); //place item  size value 
	  console.log("size :- "+sizetotal);
Posted
Updated 11-Jul-16 3:05am
v3
Comments
Kornfeld Eliyahu Peter 11-Jul-16 7:54am    
jQuery ajax call...

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900