简体   繁体   English

Javascript,如何在相同的输入类型文本字段中显示两个值?

[英]Javascript, How to show two value into same input type text field?

I want to show 10 20 in single input type text, but below option is not working. 我想在单个输入类型的文本中显示10 20,但是下面的选项不起作用。 Can any one help me 谁能帮我

Javascript:- Javascript:-

var a = 10;
var b = 20;

document.getElementById("current").value = a , b;

HTML:- HTML:-

<input type="text" id="current">

试试document.getElementById("current").value= a +" " + b;

According to your question simply use following to concat two values. 根据您的问题,只需使用以下命令来连接两个值。

var a = 10;
var b = 20;

document.getElementById("current").value = a+" "+b;

您可以执行以下操作:

document.getElementById("current").value = a + " " + b;

Try this : 尝试这个 :

var a = 10;
var b = 20;
document.getElementById("current").value = ""+a +" "+b;

Hope it Helps! 希望能帮助到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在javascript的输入数字类型字段中输入值时如何显示输入文本字段? - How to show a input text field when a value is entered in input number type field in javascript? javascript显示文本输入字段 - javascript show text input field 如何将两个输入的文本值相乘(a * b)并随javascript中的文本更改动态显示它? - How to multiple (a*b) two input text value and show it Dynamicly with text change in javascript? 如何从输入字段模态引导程序中获取值并使用 jquery 将值显示到同一模态中的另一个输入字段? - How to get value from input field modal bootstrap and show the value to another input field in the same modal with jquery? 如何使用JavaScript阻止文本字段中的任何类型的输入? - How to prevent any type of input in text field using JavaScript? 使用JavaScript单击输入类型文本时如何显示选项? - How to show choice when click on input type text using JavaScript? 如何在输入类型文本中以id的形式显示结果数据? - How to show result data in id follow value in input type text? 如何使用javascript更改隐藏类型输入字段的值 - How to change the value of a hidden type input field with javascript javascript可以“显示”字段的输入值吗? - Can javascript “show” a field's input value? 使用javascript在div中显示输入字段值 - show input field value in div using javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM