0

how can i use keyup function for this function to retrieve the value? if i press "m" all the values of m will show and if i press s all the values of "s" will show below. Thanks

<body>
<div style="text-align: center;" class="first_div" id="div_id">
    <div><p style="color:blue;"> Baby Names</p></div>
    <div><p style="color:blue;"> HOW UNIQUE IS YOUR CHILD NAMES IS ?</p>
</div>
    <label style="color: blue">Enter Full Name : </label>
    <input type="text" id="search_id" class="input_class">
    <input type="button" class="btn_class" id="btn_id" value="search">
    </br>
    <div style="color: #246eca;margin-left: 548px; font-weight: 5px; width: 300px; height: 450px; border: 1px solid" id="result"></div>
</div>
</body>
<script>
var nodes = ["maria", "mary", "marks", "michael", "seven", "sefon", "sky", "six", "tree", "ten", "team", "tee", "new", "next", "never", "neem"];
var tree = [];
function insertWord(tree, string) {
    var keys = Object.keys(tree),
        result = keys.some(function (k) {
            var i = 0;

            if (string.startsWith(k)) {
                string.slice(k.length);
                return true;
            }
            while (k[i] == string[i] && i < k.length) {
                i++;
            }

            if (i) {
                tree[k.slice(0, i)] = {[k.slice(i)]: tree[k], [string.slice(i)]: 0};
                delete tree[k];
                return true;
            }

        });

    if (!result) {
        tree[string] = 0;
    }
}
nodes.forEach(insertWord.bind(null, tree));
console.log(tree);
</script>

And i have to do this by using keyup function. after that i have to retrieve values from database and save in localstorage for further use.

Nina Scholz
  • 376,160
  • 25
  • 347
  • 392
rai
  • 27
  • 1
  • 7

0 Answers0