Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14348

Keeping post as localStorage

$
0
0
I have this script on my view below

This submits my form for me. But what I am trying now to do is some how be able to keep the posted value so when i refresh or reload page it remembers what it has posted.

I would like to know if localStorage.setItem would be good for that

And how could I use it in my form script. 

Code:
$(document).ready(function() {
    $("#range").change(function(e) {
        $("form#form-chart").submit();
           e.preventDefault();
    });
});

Code:
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<div class="panel panel-default">
    <div class="panel-heading">
        <div class="clearfix">
        <div class="pull-left">Chart <?php echo $this->input->post('range');?></div>
        <div class="pull-right">
            <form id="form-chart" action="<?php echo base_url('admin/common/dashboard');?>" method="post">
                <select name="range" class="form-control" id="range">
                    <option value="">Select View</option>
                    <option value="week">Week</option>
                    <option value="month">Month</option>
                </select>
            </form>
        </div>
        </div>
    </div>
    <div class="panel-body">
        <div id="chart" style="height: 380px;"></div>
    </div>    
</div>
</div>

Viewing all articles
Browse latest Browse all 14348

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>