How to add list of array through input element, make sure not allowing entered values and to display them in below?

Posted by Manideepgoud under JavaScript category on | Points: 40 | Views : 1166
Hi All,

In the below code snippet, Am trying to show how to add list of values in the array and not allowing once entered values and to display them in the below paragraph.
<!DOCTYPE html>
<input type="text" placeholder="Add" id="myvalue" class="searchinput" />
<button type="submit" onclick="myfunction()">Add</button>
<p id="demo"></p>
var myobject = {
name: ["Ram", "Ravi", "Ramesh"]
var myjson = JSON.stringify(myobject);
document.getElementById("demo").innerHTML = myjson;
function myfunction() {
if ("myvalue").value)) {
alert("Value exists!")
} else {"myvalue").value);
document.getElementById("demo").innerHTML = JSON.stringify(myobject) + "<br/>";
var input = document.getElementById("myvalue");
input.addEventListener("keyup", function(event) {
if (event.keyCode === 13) {

Comments or Responses

Login to post response