[英]show/hide boxes based on saved value
I have a home page that displays a bunch of tiled boxes and a link to an options page that will allow my users to hide or show any one of those boxes and then save those settings. 我有一个主页,其中显示了一堆平铺框以及一个指向选项页面的链接,该页面允许我的用户隐藏或显示其中任何一个框,然后保存这些设置。
Here is what i have so far: Options Page 这是我到目前为止的内容:选项页面
<script>
$(document).ready(function(){
$("#musicHide").click(function(){
$("#mymusic").hide();
});
$("#musicShow").click(function(){
$("#mymusic").show();
});
});
</script>
</head>
<body>
<p>My Music</p>
<input type="radio" id="musicHide" value="0"/>Hide
<input type="radio" id="musicShow" value="1" checked="checked"/>Show
</body>
Home Page: 主页:
<div class="items">
<a id="mymusic" class="box" href="#" style="background: #F8591A;">
<span>Music</span>
<img height="150px" width="150px" class="icon" src="images/my-music.png" alt="" />
</a>
Here is one problem that I currently have: When I click on the hide radio button the 'Show' radio button does not unselect. 这是我当前遇到的一个问题:单击“隐藏”单选按钮时,“显示”单选按钮不会被取消选择。
When I use the options page it does not update the home page. 当我使用选项页面时,它不会更新主页。
Also, I want to store these values per user by them hitting a save button so the next time they open the page it remembers what they wanted to show and hide. 另外,我想按用户单击保存按钮为每个用户存储这些值,以便下次他们打开页面时,它会记住他们要显示和隐藏的内容。
In order to set up your radio buttons the way you want, you'll need to add the same Name attribute to each element. 为了以所需的方式设置单选按钮,您需要向每个元素添加相同的Name属性。 eg: 例如:
<input type="radio" id="musicHide" value="0" name="radioMusic"/>Hide
<input type="radio" id="musicShow" value="1" checked="checked" name="radioMusic"/>Show
In order to persist the "Options" to the Home Page, you will need to store the preferences somehow. 为了将“选项”保留到主页,您将需要以某种方式存储首选项。 This will most likely be a database of some kind, but you can also use cookies for temporary storage. 这很可能是某种数据库,但是您也可以使用cookie进行临时存储。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.