Sandy
Sandy

Reputation: 321

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. Can any one help me

Javascript:-

var a = 10;
var b = 20;

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

HTML:-

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

Upvotes: 0

Views: 207

Answers (4)

Raghvendra Kumar
Raghvendra Kumar

Reputation: 1388

Try this :

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

Hope it Helps!

Upvotes: 0

JorgeGRC
JorgeGRC

Reputation: 1062

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

Upvotes: 1

Altmish-E-Azam
Altmish-E-Azam

Reputation: 1583

According to your question simply use following to concat two values.

var a = 10;
var b = 20;

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

Upvotes: 1

danielR
danielR

Reputation: 297

You can do something like this:

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

Upvotes: 0

Related Questions