Reputation: 488
I have a form button and I want 2 lines of text. In the form I have this
value='".$row['item'].' $'.$row['price']."'
and I get
Hot Dog
$1.00
I want to update this in JavaScript and tried this
sBtn = itm + " $" + prc;
document.getElementById(conbtn).value = sBtn;
and
sBtn = itm + "<br>$" + prc;
document.getElementById(conbtn).value = sBtn;
without success. The first gives
Hot Dog $1.00
and the second
Hot Dog<br>$1.00
Any idea how to write 2 lines from JS?
Upvotes: 0
Views: 90
Reputation: 8000
If you have a form input button, use an escaped newline in the value
property.
document.getElementById(conbtn).value = "Test 1\nTest 2";
If you have a button tag element, use a break element in the innerHTML
property.
document.getElementById(conbtn).innerHTML = "Test 1<br/>Test 2";
Upvotes: 1