jquery - 我想以条带量显示 jquery 变量数据
问题描述
我正在研究条带,并希望将 jquery 可变选定数据作为条带量。
<form action="" method="post">
<script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="<?php echo $publishable_key; ?>"
data-name="name"
data-description="testing"
data-image="test"
data-amount="<?php echo $plugin_price; ?>"
data-locale="auto"></script>
<?php /* you can pass parameters to php file in hidden fields, for example - plugin ID */ ?>
<input type="hidden" name="plugin_id" value="<?php echo $plugin_id; ?>">
</form>
我的jQuery代码
jQuery(function ($) {
$(document).ready(function () {
$("#next_btn1").click(function () {
var favorite = [];
var second = [];
$.each($("input[name='check_list[]']:checked"), function () {
favorite.push($(this).val());
second.push($(this).data('value1'));
//$("#content").append("<tr><td>" + parseFloat(favorite).toFixed(1) + "</td><td>" + second+ "</td></tr>");
});
alert("data: " + favorite.join(", "));
alert("data1: " + second.join(", "));
$('#test1').text(favorite);
$('#service').text(second);
//$('#datavalue').html(favorite,second);
});
});
});
我想获取它具有价格的复选框数据,并希望这些数据在数据量中以条带形式显示
我不知道该怎么做
解决方案
如果您想传递可变金额以显示在 Stripe 的 Checkout 中,则需要使用他们的自定义 Checkout 集成,而不是简单的data-amount
属性。
在此处查看完整示例,https://jsfiddle.net/ywain/g2ufa8xr/
$('#customButton').on('click', function(e) {
// gets amount from a form input
var amountInCents = Math.floor($("#amountInDollars").val() * 100);
// Open Checkout with further options
handler.open({
name: 'Demo Site',
amount: amountInCents,
});
e.preventDefault();
});
推荐阅读
- java - 根据用户在java中提供的名称列表列出目录中的文件
- java - 元素不可点击,因为另一个元素遮住了它
- javascript - 迷宫不循环的 BFS 算法 - Javascript
- .htaccess - htaccess 使用 www 和路径重定向
- java - 等到状态出现在 Java for 循环中
- php - 如何在php中将字符串转换为日期
- bash - 将具有相同键的变量添加到数组时枚举?
- python - Python Django:填写表单字段总是在POST上抛出错误“此字段是必需的”
- powershell - 无法将“System.String”类型的“/Action:”值转换为“System.Management.Automation.ScriptBlock”类型
- python - 从python中的路径获取子文件名而不使用split