Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/238.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 刷新页面后,保持下拉列表值处于选中状态_Javascript_Php_Mysqli - Fatal编程技术网

Javascript 刷新页面后,保持下拉列表值处于选中状态

Javascript 刷新页面后,保持下拉列表值处于选中状态,javascript,php,mysqli,Javascript,Php,Mysqli,我试图选择值,但当我刷新页面时,它会重置值 <div class="clearfix mb-20"> <div class="col s6 m6 l6"> <label class="form-label"><?= __('Gender') ?></label> <select class="input" name="filter_gender"> <option value="bot

我试图选择值,但当我刷新页面时,它会重置值

<div class="clearfix mb-20">

    <div class="col s6 m6 l6">
    <label class="form-label"><?= __('Gender') ?></label>
    <select class="input" name="filter_gender">
    <option value="both" <?= $Schedule->get("filter_gender") == "both" ? "selected" : "" ?>><?= __("Both") ?></option>
    <option value="male" <?= $Schedule->get("filter_gender") == "male" ? "selected" : "" ?>><?= __("Male") ?></option>
    <option value="female" <?= $Schedule->get("filter_gender") == "female" ? "selected" : "" ?>><?= __("Female") ?></option>
    </select>
</div>
我如何在这里添加性别

        $Schedule->set("user_id", $AuthUser->get("id"))
             ->set("account_id", $Account->get("id"))
             ->set("target", $target)
             ->set("speed", \Input::post("speed"))
             ->set("is_active", (bool)\Input::post("is_active"))
             ->set("daily_pause", $daily_pause)
             ->set("end_date", $end_date);

解决方案1:当您在表单中选择某个内容(选择选项)时,您可以更改url并添加参数。因此,在表单或表单元素上使用“onChange”事件可以更改url并添加参数

示例:
http://www.example.com?my_select_option=any_value

解决方案2:使用Cookie,设置一些带有“my_specific_form_filters”键的Cookie,并使用所选表单元素为对象赋值

示例:
{my\u select\u选项:“任意值”}

解决方案3:与cookies相同的逻辑适用于本地存储,您可以根据键值保存数据


解决方案4:也基于键值保存在PHP会话中,并在需要时检索

当用户选择值save it to localStorage时,如何在PHP中为代码添加Write Storage命令,我是PHP新手。
        $Schedule->set("user_id", $AuthUser->get("id"))
             ->set("account_id", $Account->get("id"))
             ->set("target", $target)
             ->set("speed", \Input::post("speed"))
             ->set("is_active", (bool)\Input::post("is_active"))
             ->set("daily_pause", $daily_pause)
             ->set("end_date", $end_date);