在一个页面中选择复选框使用php、javascript在另一个页面中自动选择
我设计了两个html页面,在这里我发现了两个页面中复选框的一些相同代码。我想要这个,当我在第一页中选择复选框,然后在第二页中自动选择相同的复选框时。我如何才能做到这一点 我的chk框代码共2页 您想让其他人可以复制吗 是在一个页面中选择复选框使用php、javascript在另一个页面中自动选择,php,javascript,html,Php,Javascript,Html,我设计了两个html页面,在这里我发现了两个页面中复选框的一些相同代码。我想要这个,当我在第一页中选择复选框,然后在第二页中自动选择相同的复选框时。我如何才能做到这一点 我的chk框代码共2页 您想让其他人可以复制吗 是 不我认为最简单的方法是在会话中添加一个值,然后在另一个页面上阅读。让这成为您的html表单 <form action="your/action" method="POST" name="form"> <input type="checkbox" n
不我认为最简单的方法是在会话中添加一个值,然后在另一个页面上阅读。让这成为您的html表单
<form action="your/action" method="POST" name="form">
<input type="checkbox" name="postCheckBox" value=""/>
<input type="submit" value="submit"/>
</form>
在下一个html页面中:
<input type="checkbox" name="somename" <?php echo isset($_SESSION['postCheckBox']) && $_SESSION['postCheckBox'] == 1 ? 'checked="true": ""' ?>value=""/>
复选框将自动从主页的所选价目表中选择相应的复选框。
$(“输入[名称=类别]”)。每个(函数(索引){
迭代次数=$.cookie('total_iterations');
var orgval=$(this.val();
对于(var i=1;我通过表单提交或javascript页面加载将复选框的值传递到下一页,并在需要时获取它。检查该值并使其选中=真或假,具体取决于该值。我不知道,我该怎么做?复选框将在表单中。提交表单时,在php代码中获取复选框的值。现在执行以下操作:任何时候都可以(如保存值或解释值)。如果愿意,将值设置为session,并在下一个html页面上获取。或者在重定向到下一个页面时,将值作为get param传递到带有URL的下一个页面。获取$\u get param并检查您的条件。$\u session['which-var-u-want']=您的复选框值。就是这样。这里,复选框由用户选择。您可以告诉示例如何在会话中添加到该复选框中吗?
<input type="checkbox" name="somename" <?php echo isset($_SESSION['postCheckBox']) && $_SESSION['postCheckBox'] == 1 ? 'checked="true": ""' ?>value=""/>
Checkbox will select automatically perticular checkboxes from selected price list of home page.
$("input[name=categories]").each( function (index) {
iterations = $.cookie('total_iterations');
var orgval = $(this).val();
for (var i = 1; i <= iterations; i++) {
var chkval =$.cookie("plan_item_cookie_cb_"+i);
if(chkval.trimRight() == orgval )
{
$(this).prop('checked', true);
}
};
});
$('#plan_section_id_1').click(function(){
var cookies = $.cookie();
for(var cookie in cookies) {
$.removeCookie(cookie);
}
var count=0;
//alert('outside');
$('#plan_section_id_1').find('input[type="hidden"]').each(function(){
//alert('in');
its = $('#plan_section_id_1 .total_iterations').val();
if ($(this).val().length) {
//if ($.trim($(this).val()).length) {
count++;
$.cookie('plan_item_cookie_cb_'+count,decodeURI($(this).val()),60);
//$.cookie('section-id','plan_section_id_1');
$.cookie('total_iterations',its);
}
});
});
$('#plan_section_id_2').click(function(){
var cookies = $.cookie();
for(var cookie in cookies) {
$.removeCookie(cookie);
}
var count=0;
$('#plan_section_id_2').find('input[type="hidden"]').each(function(){
its = $('#plan_section_id_2 .total_iterations').val();
if ($(this).val().length) {
//if ($.trim($(this).val()).length) {
count++;
$.cookie('plan_item_cookie_cb_'+count,decodeURI($(this).val()),60);
$.cookie('total_iterations',its);
}
});
});
$('#plan_section_id_3').click(function(){
var cookies = $.cookie();
for(var cookie in cookies) {
$.removeCookie(cookie);
}
var count=0;
$('#plan_section_id_3').find('input[type="hidden"]').each(function(){
its = $('#plan_section_id_3 .total_iterations').val();
if ($(this).val().length) {
//if ($.trim($(this).val()).length) {
count++;
$.cookie('plan_item_cookie_cb_'+count,decodeURI($(this).val()),60);
$.cookie('total_iterations',its);
}
});
});