HTA assign variable to textarea with Line Breaks

Xlacs

Board Regular
Joined
Mar 31, 2021
Messages
105
Office Version
  1. 2016
Platform
  1. Windows
Hi Everyone,

I have this simple problem, basically, I wanted a linebreak once i assign a value in my textarea but nothings seems working.
Below is my code that changes that value of textarea based on the dropdown selected.

tr><td>Template:</td><td>
<select name="template" onChange = "setTemplate(this);">
<option value="0">Admission</option>
<option value="1">Registration</option>
<option value="2">Speech on 2,3 May</option>
</select>
</td>
<tr>
<td>Message: </td>
<td>
<textarea name="adminmessage" id="adminmessage" rows="5" cols="50"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" id="submit" value="Send SMS" class="button-primary" /></td>
</tr>
</table>
</form>
<script>
test0 = "";
test1 = "test string 1 \n this is new LIne \n 3rd Line";
test2 = "test string 2 \n this is new LIne \n 3rd Line";
function setTemplate(t) {
var otionValue = t.value;
if (otionValue == "0") {
document.getElementById('adminmessage').innerHTML = test0;
} else if (otionValue == "1")
document.getElementById('adminmessage').innerHTML = test1;
else if (otionValue == "2")
document.getElementById('adminmessage').innerHTML = test2;
};
</script>
</div>
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top