Saturday 15 February 2014

javascript - How to append item to drop down and save -



javascript - How to append item to drop down and save -

i have next drop downwards list able append new listings to.

<script> function add() { var x = document.getelementbyid("myselectmenu"); var opt = document.createelement("option"); opt.value= document.getelementbyid("url").value; opt.innerhtml = document.getelementbyid("name").value; // whatever property has x.add(opt); } </script> <select id="myselectmenu"> </select> <button onclick="newsrc();">load</button> name: <input type="text" name="name" id="name"> url: <input type="url" name="url" id="url"> <button onclick="add()">add</button>

what happens (for obvious reasons) 1 time user closes browser page, list returns previou state. how create list remembers appended items?

you can utilize cookies save local info user, whenever user adds item list update local cookie , when page loads first time after user comes utilize onload event load items cookie list.

this ofcourse saved on browser level user, meaning if same user opens page in difrent browser or on difrent device these changes not saved.

to save info on global nature need server side proccessing.

javascript jquery html

No comments:

Post a Comment