简体   繁体   中英

How would I go about creating Textbox.Text combination WYSIWYG

WYSIWYG = What you see is what you get.

Some Info:

Let's say I have 2 Text Boxes and one Label: Textbox1, Textbox2, Label.

For, let's say, a Custom ID I want to provide a text and a number. These two are combined to create the ID: Prefix + Integer.

Label.text = Textbox1.Text + Textbox2.Text"

But that is not what I'm interested in.

The Question:

How would I go about making a JavaScript to make "as you type" functionality to display on the result on label to show the user what their Custom ID would look like?

I hope this is what you were looking for.

HTML:

<label id="lab">My label:</label><br><br>
Prefix: <input type="text" id="txtarea1"><br>
Number: <input type="text" id="txtarea2">

JS:

document.getElementById("txtarea1").onkeyup = function() {
    document.getElementById("lab").innerHTML = document.getElementById("txtarea1").value + document.getElementById("txtarea2").value; 
}
document.getElementById("txtarea2").onkeyup = function() {
    document.getElementById("lab").innerHTML = document.getElementById("txtarea1").value + document.getElementById("txtarea2").value; 
}

Fiddle .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM