javascript - Fault with appending item to drop down (local storage) -
i have following code, works well.
<div style="padding:2px;"> <form action='test.php' name ='gen' method='post'> <input type='text' name='pass' placeholder="insert website" size="10"> <input type='submit' value='open'> </form> </div> <?php $random = 'specificsaltcode'; // specific salt $pass2 = $_post['pass'] . $random; // add user input $pass = md5($pass2); // md5() both $url = 'http://www.website'.$_post['pass'].'random'.$pass.'randomurlcontinued'; // url need echo '<iframe id="iframe1" name="iframe1" scrolling="yes" src="' . $url . '" style="position: absolute; left: 0px; top: 26px;" width="99%" height="88%" border="0"></iframe>'; ?>
this hashes user input string , sends original input string, along hashed number iframe url. works me.
however, rather send url iframe, need send drop down list , store using local storage.
i have following code drop down.
<style> #choice option { color: black; } .empty { color: gray; } </style> <script> var vm = function () { this.annotationlist = ko.observable(); this.area = ko.observablearray(); this.append = function () { this.area.push(this.annotationlist()); localstorage.setitem('labelobject',this.annotationlist()); localstorage.setitem('labelobjectlist',this.area()); }; }; var existannotationmodel = new vm(); ko.applybindings(existannotationmodel); </script> <script> $("#choice").change(function () { if($(this).val() == "0") $(this).addclass("empty"); else $(this).removeclass("empty") }); $("#choice").change(); </script> <form > <span class="btn-group"> <select name="select" data-bind="options: area" id="choice"> <option value="0" selected="selected">choose website</option> </select> <input id="editexistannotation" data-bind="value: annotationlist" type="text" placeholder="enter website"/> </span> <button id="buttonsave" type="submit" data-bind="click:append" >save</button> </form> <div id="labellist" class="btn-group" ></div>
however, drop down method not store these appends. infact, doesn't add items menu @ all. i'd add item drop down, , save using local storage, when user refreshes page, appends still there.
so 2 issues, how pass url drop down, , how make drop down save appended items.
also, not concerned on security issues @ moment.
Comments
Post a Comment