Hi guys,

I cant seem to work out a way to keep my paragraphs when using a text area as part of a form.

I send the form using ajax and then display the text again in a textarea to allow editing before finally displaying it on a standard page.

This is the form I am currently using:

<form action="javascript:insertChunk()" method="post" >
<h3>Chunk Name<br />
<input type="text" id="txtChunkTitle" name="txtChunkTitle" length="42"/></h3>
						
<h3>Chunk Description<br />
<textarea type="text" name="txtChunkContent" id="txtChunkContent" cols="30" rows="15"></textarea></h3>
						
<div id="addChunkBut">
<input type="button" name="submit" value="Click To Create Chunk" onclick="insertChunk()" />
</div>
</form>

I do nothing special to the input after:

var chunkTitle= document.getElementById('txtChunkTitle');
var chunkContent = document.getElementById('txtChunkContent');
params = "?chunkTitle=" + chunkTitle.value + "&chunkContent=" + chunkContent.value;

Then pass it through ajax to php file

$chunkTitle = $_GET['chunkTitle'];
$chunkContent = $_GET['chunkContent'];

I then store that into the database using a standard insert into sql statement.


I have tried playing around with various things i have seen on the net but to no avail so thought id show the base form and see if someone knows how to do this or if its possible.

Thanks

Solved using escape() before sending via AJAX

Please mark thread close/solved

Why not mark it solved yourself? The link is right there at the bottom of the thread :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.