A little help required

Discussion in 'jQuery' started by hallianonline, Mar 17, 2013.

  1. #1
    hello everyone i am facing a little problem
    I have a 3 dependent selectboxes and i want to save the selected values in the session so user can remember what category i selected before

    here is my code pelase tell me what code i use in it to save the last selected values

    <script type="text/javascript"><!--

    $(document).ready(function(){
    $("#cPath").change(modelList);
    $("#select_model").change(yearList);
    //$("#select_year").focus();
    $("#select_year").change(function()
    {
    var baseDirectory=document.getElementById("basemodulepath").value;
    var cPath1=$("#cPath").val();
    var cPath2=$("#select_model").val();
    var cPath3=$("#select_year").val();
    window.location=(baseDirectory+"index.php?main_page=index&cPath="+cPath1+"_"+cPath2+"_"+cPath3);
    }
    );
    });
    var modelList=function model_list(){
    var baseDirectory=document.getElementById("basemodulepath").value;
    var cPath=document.getElementById("cPath").value;
    $.ajax({
    type: 'POST',
    url:baseDirectory+"modellist.php",
    data:"cPath="+cPath+"&my=1",
    success: function(data){
    // alert(data);
    if(data!=""){
    arrayVar=new Array();
    arrayVar=data.split("|");
    arrayVarId=new Array();
    arrayVarId=arrayVar[0].split("^");
    arrayVarName=new Array();
    arrayVarName=arrayVar[1].split("^");
    $('#select_model').html("");
    $('#select_model').append("<option value=''><?php echo TEXT_PLEASE_SELECT; ?><\/option>");
    for(i=1;i<arrayVarId.length-1;i++)
    {
    $('#select_model').append($("<option><\/option>").attr("value",arrayVarId).text(arrayVarName));
    }
    }
    }
    });
    };
    var yearList=function year_list(){
    var baseDirectory=document.getElementById("basemodulepath").value;
    var cPath=document.getElementById("select_model").value;
    $.ajax({
    type: 'POST',
    url:baseDirectory+"modellist.php",
    data:"cPath="+cPath+"&my=2",
    success: function(data){
    if(data!=""){
    arrayVar=new Array();
    arrayVar=data.split("|");
    arrayVarId=new Array();
    arrayVarId=arrayVar[0].split("^");
    arrayVarName=new Array();
    arrayVarName=arrayVar[1].split("^");
    $('#select_year').html("");
    $('#select_year').append("<option value=''><?php echo TEXT_PLEASE_SELECT; ?><\/option>");

    for(i=1;i<arrayVarId.length-1;i++)
    {
    $('#select_year').append($("<option><\/option>").attr("value",arrayVarId).text(arrayVarName));
    }
    }
    }
    });
    };
    //--></script>

     
    hallianonline, Mar 17, 2013 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    Save them where? In the browser if the user submits? On the server?
     
    Rukbat, Mar 17, 2013 IP
  3. hallianonline

    hallianonline Active Member

    Messages:
    104
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #3
    in the browser when user submits
     
    hallianonline, Mar 18, 2013 IP
  4. artus.systems

    artus.systems Well-Known Member

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    103
    #4
    Use js cookie
     
    artus.systems, Mar 18, 2013 IP
  5. hallianonline

    hallianonline Active Member

    Messages:
    104
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #5
    i dont know much about programming how can i do this
     
    hallianonline, Mar 18, 2013 IP
  6. jimarmstrong79

    jimarmstrong79 Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #6
    Visit http://www.w3schools.com/js/js_cookies.asp this will help you to understand Js cookies.
     
    jimarmstrong79, Mar 25, 2013 IP