我想在文本框中将总值和计数器值传递给另一个php页面,并保存到数据库中
i want to pass total and counter value to another php page in a text box and save to database?
我想将总值和计数器值传递到文本框中的另一个PHP页面,并保存到数据库中。
{
var price =10;
//price
$(document).ready(function() {
var $cart = $('#selected-seats'), //Sitting Area
$counter = $('#counter'), //Votes
$total = $('#total'); //Total money
var sc = $('#seat-map').seatCharts({
map: [ //Seating chart
'_______a',
'________',
'aa____aa',
'aa____aa',
'aa____aa',
'aa____aa',
'aa____aa',
'aa____aa',
'aa____aa',
'aa____aa',
'aa____aa'
],
naming: {
top: false,
getLabel: function (character, row, column) {
return column;
}
},
legend: { //Definition legend
node: $('#legend'),
items: [
[ 'a', 'available','Available' ],
[ 'a', 'unavailable', 'Booked']
]
},
click: function () { //Click event
if (this.status() == 'available') { //optional seat
$('<li>R'+(this.settings.row+1)+' S'+this.settings.label+'</li>')
.attr('id', 'cart-item-'+this.settings.id)
.data('seatId', this.settings.id)
.appendTo($cart);
$counter.text(sc.find('selected').length+1);
$total.text(recalculateTotal(sc)+price);
return 'selected';
} else if (this.status() == 'selected') { //Checked
//Update Number
$counter.text(sc.find('selected').length-1);
//update totalnum
$total.text(recalculateTotal(sc)-price);
//Delete reservation
$('#cart-item-'+this.settings.id).remove();
//optional
return 'available';
} else if (this.status() == 'unavailable') { //sold
return 'unavailable';
} else {
return this.style();
}
}
});
//sold seat
sc.get(['1_8','4_4','4_5','6_6','6_7','8_5','8_6','8_7','8_8','10_1', '10_2']).status('unavailable');
});
//sum total money
function recalculateTotal(sc) {
var total = 0;
sc.find('selected').each(function () {
total += price;
});
return total; //here returning total amount
}
}
// You can use this "Javascript" code to navigate to the next page
window.location = "savetodbpage.php?total=" + $total + "&counter=" + $counter
// PHP To receive the params
<?php
$total = @$_GET[ "total" ];
$counter = @$_GET[ "counter" ];
// Below you can either update / insert these values into your database. You have not mentioned much in your question so this is how far I can go helping you. Look up on SQL Insert / Update queries depending on what you actually want to do...
?>
相关文章:
- 如何通过php页面将数据库值检索到jquery自动完成框中
- 通过php页面中的js强制下载txt
- 在PHP中使用javascript更改页面标题'if'
- 如何将字符串值从php页面发送到java脚本页面
- Javascript/Jquery/PHP加载页面-如何
- PHP-如何重定向到同一页面并更改DOM's
- 倒计时计时器应该持续两个php页面
- 如何在一页网站中使用PHP重定向到一个页面
- 如何从特定页面中提取php变量值
- 重定向基于提交的网关页面PHP
- 在“onexit”或“onsubmit”之后,查询mysql并填充表单字段,而无需离开页面php js
- AJAX 传输页面 PHP.
- 从另一个页面 PHP/javascript 获取 document.getElementsByName
- 强制灯箱在父页面 php JavaScript 中打开
- 从Facebook页面PHP获取帖子
- 首先执行 JS,然后在 上转到“页面.php
- 创建jQuery数组变量和传输数组到另一个页面PHP
- 如何将列表框的值存储到数组中,然后使用它将其数据显示到另一个页面 php 中
- 登录页面PHP和JavaScript
- 表单数据不可见的新页面- PHP + Javascript