Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript can';刷新页面时不发送不同的URL_Javascript_Url_Checkbox - Fatal编程技术网

Javascript can';刷新页面时不发送不同的URL

Javascript can';刷新页面时不发送不同的URL,javascript,url,checkbox,Javascript,Url,Checkbox,我在这里读了很多文章,但没有找到解决方案,我尝试了很多建议。所以我希望通过这种方式得到帮助。 我喜欢在选中带有参数checkbx=1和pagerefresh的url时读取复选框状态并发送,在未选中参数checkbx=0时发送。执行时,我不能取消选中该复选框。它会立即重置为“已检查”。但是地址行中的URL显示…checkbx=0 提前感谢,, 这是我的密码: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jqu

我在这里读了很多文章,但没有找到解决方案,我尝试了很多建议。所以我希望通过这种方式得到帮助。 我喜欢在选中带有参数checkbx=1和pagerefresh的url时读取复选框状态并发送,在未选中参数checkbx=0时发送。执行时,我不能取消选中该复选框。它会立即重置为“已检查”。但是地址行中的URL显示…checkbx=0

提前感谢,, 这是我的密码:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox" value="test" id="check"><label for="check">Item</label>

 <script>


$(function () {

$('#check').prop("checked", !!localStorage.getItem("darkMode"));

$('#check').on("click", function() {
  var url;
  if ($(this).is(":checked")) {
    localStorage.setItem('darkMode', 'true');
    $('img').attr('src', '/full_logo_transparent.png');
    $('link#hueman-main-style-css').attr('href', '/darkstyle.min.css');
    console.log('Dark Mode enabled');
    url = 'index1.php?checkbx=1';
  } else {
    localStorage.setItem('darkMode', 'false');
    $('link#hueman-main-style-css').attr('href', '/main.min.css');
    console.log("No Dark Mode");
    url = 'index1.php?checkbx=0';
  }
  window.location.href = url;
});
});
</script>

项目
$(函数(){
$('#check').prop(“checked”),!!localStorage.getItem(“darkMode”);
$('#check')。在(“单击”,函数()上){
var-url;
如果($(this).is(“:checked”)){
setItem('darkMode','true');
$('img').attr('src','/full_logo_transparent.png');
$('link#hueman main style css').attr('href','/darkstyle.min.css');
console.log(“已启用暗模式”);
url='index1.php?checkbx=1';
}否则{
setItem('darkMode','false');
$('link#hueman main style css').attr('href','/main.min.css');
console.log(“无暗模式”);
url='index1.php?checkbx=0';
}
window.location.href=url;
});
});

我在朋友的帮助下解决了这个问题,没有JS

$che = '';
if($_SESSION['proc_all'] == 1) $che = ' checked';

?>
<input type="checkbox"<?php echo $che; ?> onclick="window.parent.location='<?php echo $_SERVER['SCRIPT_NAME']."?aktion=1&amp;todo=uebersicht&amp;proc_all=chenge"; ?>'" class="diasel"><label for="check"> Checkbox</label>
$che='';
如果($_SESSION['proc_all']=1)$che='checked';
?>

你能详细说明一下你想完成什么吗?大多数引用URL查询部分的集成都使用location.search。我看不到您的代码中有任何地方引用了URL来设置任何元素的值。我的目标是在页面刷新时向服务器发送一个带有参数的URL,然后我喜欢使用$\u GET['checkbx']读取参数并获取用于构建sql查询的值。您是否取消了设置?是否有任何原因需要使用页面刷新发送复选框值?您已经将AJAX加载到页面中,因此您可以向服务器发送POST请求以使其更简单。否则,您需要在页面脚本中添加一些逻辑来检查URL参数,然后将checkbox元素的值设置为checked/unchecked。好的,我将阅读有关使用AJAX的POST请求的内容,并尝试这种方法。我明天会给出反馈。谢谢stephancasas。你读0或1的代码在哪里?查询参数是字符串,0!='0',