Jump to content

Recommended Posts

Hi all,

 

I am working with a drop down to auto populate a textarea with preset fields / lines. The issue I keep having is the formatting to the text being populated has no lines/breaks to it. Below is the current java script snip it and the form as it stands. I am looking to find if there would be a better method to doing this, including creating a php form utlizing ajax to pull the information. Thoughts?

 

Javascript:

<script type="text/javascript">function updateTextBox(val)
{
if(val == "1")
{
document.forms['Form'].elements['TextBox'].value = "Line 1, Line 2, Line 3, Line 4";<--- In theory should display as entered, however this does not occur on any line break/Also /n/p/br/&nbsp do not work to adding lines/breaks.
}
else if(val == "2")
{
document.forms['Form'].elements['TextBox'].value = "Line 1 &nbsp Line 2";
}
}


</script>

 

 

Form:

<form name="Form">
<select onchange='updateTextBox(this.value)'>
<option value=""></option>
<option value="1">Test</option>
<option value="2">Test2</option>
</select>
<tr>
<td> <div align="left"><span id="copy">
 <textarea name="TextBox" cols="29" rows="30" style="font-family: Verdana" class="size12"></textarea>
 <br />
</span></div>
<table width="20%" border="0" align="left">
	<tr><td><input name="Button" type="button" onclick="javascript:selectcopy('Form.textbox')" value="Copy Notes" /></td></tr>
	<tr><td><input name="RESET" type="RESET" value="Clear Notes" /></td></tr>
</table>
</div>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.