I have designed a text field with an Add-Email button. On each click I want the text field value to be appended to a file.
A dropdown list is there which will read the data from the file and show it to user.
I have implemented the second part to populate the data from the file to the dropdown, but I'm stuck with the first part.
Is this the right way to implement this feature by using file read/write or any alternative is available in JavaScript?
Below is the code what i have tried :
drop down box html :
select name="Email" id="Email"
function to populate the file data to drop down :
<script>
$.getJSON("C:/test.txt", function( json ) {
$.each(json, function(key, value) {
$('select[name=Email]').append('<option value="' + value + '">' + json[key] + '</option>');
});
});
</script>
text file :
{
"Key1": "Test1",
"Key2": "Test2",
"Key3": "Test3",
"Key4": "Test4"
}
input text filed :
input id="Email_store" type="text"
Button :
button id=Add_Email onclick="saveEMail()"
Now what i want is when a user enters any value in the text field and clicks on the save button, the data should be appended to the file without replacing the existing values in the file.