Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
197 views
in Technique[技术] by (71.8m points)

javascript - Difference between input change and manual input

At work we use a program that allows us to create html forms to use with their mobile app. The form allows javascript, however, upon submission any element content changed using innerHTML property is erased and the default content is the whats submitted (blank). I have been searching for a work around and noticed if instead I use an input as the element and change its value with javascript, upon submission the changed value will not be erased if the user clicks into and adds one more character

My question is how does the submission button differentiate between a changed value via js, vs a manually inputted value? And is there a property I can use to make the form think a value was inputted manually?

I am limited to what the app allows me to do, i am unable to change anything about the submission button

example

function addElement() {
    document.getElementById('div1').value = "Changed Value";
}
            
<div><button onclick="addElement()">Button</button></div>
  <input id="div1">
question from:https://stackoverflow.com/questions/65925790/difference-between-input-change-and-manual-input

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...