Rick Harrison wrote:

> I have to create a little chat program with LiveCode on a LiveCode
> server. Currently I have a textarea text box to accept the user’s
> input, but it won’t keep any formatting at all, not even carriage
> returns, line feeds, or bold faced text.  I also have to put that
> information into a database, so I can pull it out later.
>
> How are you handling such things with LiveCode?  One would think
> that by this time we would have something simple that would deal
> with this! It has to be a common problem, and one would think
> their would be a common solution to it.
>
> Suggestions?


As Alex noted, not a LC thing, just a limitation of HTML's textArea.

You may find it easier to set the contenteditable property of a container element like div or p, and then you can retrieve the inner HTML of that element with:

  var tFldMainHTML = document.getElementById("fldMain").innerHTML

Save the example below to a text file and run in your browser. There's extra stuff there just for appearance, but the meat of it is that one line.

Once the page is loaded, copy some styled text and paste it into the field. When the button's clicked you'll see the full HTML tags in an alert dialog.

--
 Richard Gaskin
 Fourth World Systems


--------------------------------------------------

<!DOCTYPE html>
<htmtl>
<head>
<script>
function GetContents() {
        var tFldMainHTML = document.getElementById("fldMain").innerHTML
        alert( tFldMainHTML );
}
</script>
<style>
#fldMain {
        border: 1px solid blue;
        padding: 4px;
        width: 400px;
        height: 200px;
        overflow: scroll;
}
[contenteditable] {
        outline: 1px solid blue;
}
</style>
</head>
<body>
 <p id="fldMain" contenteditable="true"></p>
 <button type="button" onClick="GetContents();">Show InnerHtml</button>
</body>
</html>

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to