session stroage to save dropdown values

时间:2016-02-12 21:33:36

标签: javascript jquery html

I have these two scripts. The first saves the storage of the model then after the page refreshes loads that model into the dropdown and opens the text file containing the corresponding year values into the second dropdown.

The second should do the same which everything is working great. The storage is saving but the dropdown is not populating? Is the reason it is not displaying in the dropdown because the options are not located in the html?

Also is there a more efficient way to combine these two. I have a set of 6 dropdowns all dependent on the other that I would like to do the same.

import re
a='[02/Jan/2015:08:07:32] "GET /click?article_id=162&user_id=5475 HTTP/1.1" 200 4352 '

for line in a:
    match =  re.search("\[(\d+\/[A-Za-z]+\/\d+\:\d+\:\d+\:\d+)\] \"GET\/click\article_id\=(\d+)\&user_id\=(\d+) HTTP\/1\.1\" (\d+) (\d+)",line)
    if match: 
         print "%s   %s  %s %s %s  " %( match.group(1), match.group(2), match.group(3), match.group(4), match.group(5) )

output 
02/Jan/2015:08:07:32   162  5475 200 4352

2 个答案:

答案 0 :(得分:1)

Try this:

TargetGenome

答案 1 :(得分:0)

我在从文本文件中提取时已经想出了如何做到这一点。我必须将sessionsotrage.GetItem绑定到.load:

$(function() {
        $('#vehic_sel_model').change(function() {
            sessionStorage.setItem('model', this.value);

        });

       $('#vehic_sel_year').change(function() {
            sessionStorage.setItem('year', this.value);

       if(sessionStorage.getItem('model')){
            $('#vehic_sel_model').val(sessionStorage.getItem('model'));
            $("#vehic_sel_year").load("/v/vehicle-selection/cache/" + sessionStorage.getItem('model') + ".txt", function(){
              $('#vehic_sel_year').val(sessionStorage.getItem('year'));
        });