形式:
<?php foreach($db->query("SELECT * FROM `company_details` WHERE id='$userid' LIMIT 1 ") as $edit) {
echo '<form class="form-horizontal" id="productdetail_form" name="productdetail_form" method="post" style="padding:20px 0;">
<input type="hidden" name="productdetail_formhide" id="productdetail_formhide" value="productdetail_formhide"/>
<input type="hidden" name="productdetail_city" id="productdetail_city" value="'.$edit['city'].'">
<input type="hidden" name="cid" id="cid" value="'.$userid.'">
<input type="hidden" name="productdetail_cname" id="productdetail_cname" value="'.$edit['comp_name'].'">';}?>
<h2>Manufacture</h2>
<div class="row"><div class="col-sm-4" >
<label class="checkbox-inline no_indent">
<input type="checkbox" class="check" id="Basic_Amenities" name="Basic_Amenities[]" value="Water Sports Equipment" />Water Sports Equipment
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" class="check" id="Basic_Amenities" name="Basic_Amenities[]" value="Adventure Sports" />Adventure Sports
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" class="check" id="Basic_Amenities" name="Basic_Amenities[]" value="Billiard/Snooker/polls"/>Billiard/Snooker/polls
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" class="check" id="Basic_Amenities" name="Basic_Amenities[]" value="Gym Fitness Equipment" >Gym Fitness Equipment
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" class="check" id="Basic_Amenities" name="Basic_Amenities[]" value="Medal Trophy" >Medal Trophy
</label>
</div>
<div class="col-sm-4">
<label class="checkbox-inline no_indent">
<input type="checkbox" id="Basic_Amenities" name="Basic_Amenities[]" value="Playground Equipment" >Playground Equipment
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" id="Basic_Amenities" name="Basic_Amenities[]" value="Sports Bags" >Sports Bags
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" id="Basic_Amenities" name="Basic_Amenities[]" value="Sports Apprarels" >Sports Apprarels
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" id="Basic_Amenities" name="Basic_Amenities[]" value="Sports Bikes / Cycles" >Sports Bikes / Cycles
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" id="Basic_Amenities" name="Basic_Amenities[]" value="Sports Goods" >Sports Goods
</label>
</div>
<div class="col-sm-4">
<label class="checkbox-inline no_indent">
<input type="checkbox" id="Basic_Amenities" name="Basic_Amenities[]" value="Sports Nutrition" >Sports Nutrition
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" id="Basic_Amenities" name="Basic_Amenities[]" value="Sports Wear Fabric">Sports Wear Fabric
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" id="Basic_Amenities" name="Basic_Amenities[]" value="Sports Flooring" >Sports Flooring
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" id="Basic_Amenities" name="Basic_Amenities[]" value="Sports Shoes">Sports Shoes
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" id="Basic_Amenities" name="Basic_Amenities[]" value="Sports Raw Materials" >Sports Raw Materials
</label></br>
<div class="form-group">
<label for="name" class="col-sm-2 control-label"></label>
<div class="col-sm-10 text-center">
<input type="submit" id="productdetail_submit" name="productdetail_submit" value="Submit Product Details" class="btn btn-success">
</div>
</div>
</div>
</div>
</form>
?>
$( "#productdetail_form" ).submit(function( event ) {
event.preventDefault();
var productdetail_formhide = $("#productdetail_formhide").val();
var productdetail_cid = $("#cid").val();
var productdetail_cname = $("#productdetail_cname").val();
var Basic_Amenities= new Array();
var Basic_Amenities = new Array();
$("#manufacture :checkbox:checked").each(function() {
Basic_Amenities.push($(this).val());
});
var productdetail_city = $("#productdetail_city").val();
var manufacture = $("a[name=tab1]").data("index");
$("#productdetail_form").empty();
alert(Basic_Amenities);
alert(manufacture);
$("#productdetail_form").prepend('<div id="productdetail" style="color:red;">Submitting data..... Please Wait.. </div>');
$.post("merchant/edit_ajax.php",
{
productdetail_formhide:productdetail_formhide,
productdetail_cid:productdetail_cid,
productdetail_cname:productdetail_cname,
Basic_Amenities:Basic_Amenities,
productdetail_city:productdetail_city,
manufacture:manufacture,
},
function(data,status){
$("#productdetail").hide();
$("#productdetail_form").prepend(data);
});
});
以下代码位于ajax.php
//for manufactures where cid='$userid' AND categories='Manufaturers'
if(isset($_POST['productdetail_formhide'])=='productdetail_formhide'){
$q = $db->prepare("UPDATE `business_category` SET cid=:cid, comp_name=:comp_name, categories=:categories, subcategories=:subcategories, city=:city ,activation='0' WHERE cid='$userid' AND categories='Manufaturers'");
foreach($_POST['Basic_Amenities'] as $basic){
$q->execute(array(':cid'=>$_POST['cid'].'',
':comp_name'=>$_POST['productdetail_cname'].'',
':categories'=>$_POST['manufacture'].'',
':subcategories'=>$basic.'',
':city'=>$_POST['productdetail_city'].''));
}
if($q==true){
echo '<div align="center" >
<div style="color:green;"> Thank You ..Your details submitted sucessfully <br> Your Profile Will Be Activated Soon ..!!</div>
</div>';
exit();
}
else{
echo '<div style="color:red;">business details not submitted</div>';
}
}
答案 0 :(得分:0)
缺少脚本标记。试试这个。
<?php foreach($db->query("SELECT * FROM `company_details` WHERE id='$userid' LIMIT 1 ") as $edit) {
echo '<form class="form-horizontal" id="productdetail_form" name="productdetail_form" method="post" style="padding:20px 0;">
<input type="hidden" name="productdetail_formhide" id="productdetail_formhide" value="productdetail_formhide"/>
<input type="hidden" name="productdetail_city" id="productdetail_city" value="'.$edit['city'].'">
<input type="hidden" name="cid" id="cid" value="'.$userid.'">
<input type="hidden" name="productdetail_cname" id="productdetail_cname" value="'.$edit['comp_name'].'">';}?>
<h2>Manufacture</h2>
<div class="row"><div class="col-sm-4" >
<label class="checkbox-inline no_indent">
<input type="checkbox" class="check" id="Basic_Amenities" name="Basic_Amenities[]" value="Water Sports Equipment" />Water Sports Equipment
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" class="check" id="Basic_Amenities" name="Basic_Amenities[]" value="Adventure Sports" />Adventure Sports
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" class="check" id="Basic_Amenities" name="Basic_Amenities[]" value="Billiard/Snooker/polls"/>Billiard/Snooker/polls
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" class="check" id="Basic_Amenities" name="Basic_Amenities[]" value="Gym Fitness Equipment" >Gym Fitness Equipment
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" class="check" id="Basic_Amenities" name="Basic_Amenities[]" value="Medal Trophy" >Medal Trophy
</label>
</div>
<div class="col-sm-4">
<label class="checkbox-inline no_indent">
<input type="checkbox" id="Basic_Amenities" name="Basic_Amenities[]" value="Playground Equipment" >Playground Equipment
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" id="Basic_Amenities" name="Basic_Amenities[]" value="Sports Bags" >Sports Bags
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" id="Basic_Amenities" name="Basic_Amenities[]" value="Sports Apprarels" >Sports Apprarels
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" id="Basic_Amenities" name="Basic_Amenities[]" value="Sports Bikes / Cycles" >Sports Bikes / Cycles
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" id="Basic_Amenities" name="Basic_Amenities[]" value="Sports Goods" >Sports Goods
</label>
</div>
<div class="col-sm-4">
<label class="checkbox-inline no_indent">
<input type="checkbox" id="Basic_Amenities" name="Basic_Amenities[]" value="Sports Nutrition" >Sports Nutrition
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" id="Basic_Amenities" name="Basic_Amenities[]" value="Sports Wear Fabric">Sports Wear Fabric
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" id="Basic_Amenities" name="Basic_Amenities[]" value="Sports Flooring" >Sports Flooring
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" id="Basic_Amenities" name="Basic_Amenities[]" value="Sports Shoes">Sports Shoes
</label><br/>
<label class="checkbox-inline no_indent">
<input type="checkbox" id="Basic_Amenities" name="Basic_Amenities[]" value="Sports Raw Materials" >Sports Raw Materials
</label></br>
<div class="form-group">
<label for="name" class="col-sm-2 control-label"></label>
<div class="col-sm-10 text-center">
<input type="submit" id="productdetail_submit" name="productdetail_submit" value="Submit Product Details" class="btn btn-success">
</div>
</div>
</div>
</div>
</form>
<script>
$( "#productdetail_form" ).submit(function( event ) {
event.preventDefault();
var productdetail_formhide = $("#productdetail_formhide").val();
var productdetail_cid = $("#cid").val();
var productdetail_cname = $("#productdetail_cname").val();
var Basic_Amenities= new Array();
var Basic_Amenities = new Array();
$("#manufacture :checkbox:checked").each(function() {
Basic_Amenities.push($(this).val());
});
var productdetail_city = $("#productdetail_city").val();
var manufacture = $("a[name=tab1]").data("index");
$("#productdetail_form").empty();
alert(Basic_Amenities);
alert(manufacture);
$("#productdetail_form").prepend('<div id="productdetail" style="color:red;">Submitting data..... Please Wait.. </div>');
$.post("merchant/edit_ajax.php",
{
productdetail_formhide:productdetail_formhide,
productdetail_cid:productdetail_cid,
productdetail_cname:productdetail_cname,
Basic_Amenities:Basic_Amenities,
productdetail_city:productdetail_city,
manufacture:manufacture,
},
function(data,status){
$("#productdetail").hide();
$("#productdetail_form").prepend(data);
});
});
</script>