Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67469

How to save the table data in local storage using javascript?

$
0
0

How to save the user input table data in to local storage using JavaScript. I want to save user input in local storage,
Please see my code that I have tried,

<script type="text/javascript">
function getValue(){

        var selectedText = $("#ddlFruits").find("option:selected").text();
        if(selectedText!="None"){
            var display = document.getElementById("display");
             $('#display tr:last').after('<tr><th>'+selectedText+'</th></tr>');

document.getElementById('ddlFruits').selectedIndex = 0;


    }
}



<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<select id="ddlFruits" onchange="getValue();">
  <option value="">None</option>
  <option value="1">Apple</option>
  <option value="2">Mango</option>
  <option value="3">Orange</option>
</select>


<table border="1" id="display">
  <tr>
    <th>Fruits</th>
  </tr>r>

Viewing all articles
Browse latest Browse all 67469

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>