douhan9748 2019-01-08 11:19
浏览 159
已采纳

如何在页面刷新后“保存”复选框的状态

I'm trying to memorize the status of the check box for a preferences page. The status should remain selected or deselected according to the user's choice.

<div class="tab-pane" id="Notifiche">
    <div class="row">
        <div class="col-sm-4">
             <h5>Able/Disable Notify</h5><br>
        </div>
        <div class="col-sm-4">
            <label class="container">
               Able <input type="checkbox" name="check" value="1" <?php if (isset($_POST['check'])) { echo ($_POST['check']=='1' ? 'checked' : '');}?> >
           <span class="checkmark"></span>
           </label>
        </div>
        <div class="col-sm-4"></div>
    </div>
</div>

after page refresh it returns to normal state

  • 写回答

1条回答 默认 最新

  • douxiong4892 2019-01-08 12:57
    关注

    you can achieve this by using local storage

    like this way u can store

    window.localStorage.setItem('user', val);
    

    and this way can get on page refresh

    window.localStorage.getItem('user');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 全一数分解素因子和素数循环节位数
  • ¥15 ffmpeg如何安装到虚拟环境
  • ¥188 寻找能做王者评分提取的
  • ¥15 matlab用simulink求解一个二阶微分方程,要求截图
  • ¥30 乘子法解约束最优化问题的matlab代码文件,最好有matlab代码文件
  • ¥15 写论文,需要数据支撑
  • ¥15 identifier of an instance of 类 was altered from xx to xx错误
  • ¥100 反编译微信小游戏求指导
  • ¥15 docker模式webrtc-streamer 无法播放公网rtsp
  • ¥15 学不会递归,理解不了汉诺塔参数变化