Home > Software design >  Make user change value of Javascript
Make user change value of Javascript

Time:11-13

I have a problem where i want to let the user input their name in a text field and make that change a value in javascript

`

Splain.addEntry({
  people:{
    all:["{{THISNEEDSINPUT}}"],
},

How can i make this possible?

CodePudding user response:

You can do the following :

<input id="name-input" />
const obj = {
  people: {
    all: [ "{{THISNEEDSINPUT}}" ],
}

window.onload = () => {
  const input = document.getElementById('name-input')

  input.onkeydown = () => {
    obj.people.all[0] = input.value
  }
}

Splain.addEntry(obj)
  • Related