Home > front end > [with] consult a js writing: real-time access to multiple input values and splicing display
[with] consult a js writing: real-time access to multiple input values and splicing display
Time:10-21
needs: to monitor the input motion, real-time tips,
Online to find a piece of code, it is a single input real-time tips, following can run normally,
& lt; div>
<script> Var oBtn_title=document. GetElementById (' showtips_title '); Var oTi_all=document. GetElementById (' showtips_all ');
If (' the oninput oBtn_title) in { OBtn_title. AddEventListener (" input ", getWord, false); } else { OBtn_title. Onpropertychange=getWord; }
The function getWord () { OTi_all. InnerHTML=oBtn_title. Value; } </script>
Now have more than one input, need combination shows in showtips_all, No, because your skill didn't change success,
& lt; div>
Now want to add showtips_subject with showtips_date also entered the hints in the text, (hint text consists of three segments: showtips_subject showtips_date showtips_title
Please give directions!
CodePudding user response:
The three variables, and then one by one to monitor records can be...
<script> Let the subject=' '; Let the date=' '; Let the title=' ';
Showtips_subject. Onchange=function () { Subject=this. The value; Showall () } Showtips_date. The oninput=function () { Value; the date=this. Showall () } Showtips_title. The oninput=function () { Title=this. Value Showall () }
The function showall () { Showtips_all. InnerHTML=` ${subject} ${date} ${title} ` } </script>
CodePudding user response:
<script> Var sub=document. GetElementById (' showtips_subject), The date=document. GetElementById (' showtips_date), Title=the document. The getElementById (' showtips_title), All=document. GetElementById (' showtips_all ') Document. The addEventListener (' input ', function () { All the innerHTML=sub. Value + date. Value value + title.}) Sub. Onchange=function () { All the innerHTML=sub. Value + date. Value value + title.} </script>