Click to See Complete Forum and Search --> : Form Text Box Formatting


FarFlungFish
04-29-2004, 08:08 AM
Hello all; big hello to everyone before i post as most people i have found never say hello and use forums like these as "one-shot" help. So HI

I am currently creating an article system which just uses a standard connection to an access db (just a little outline, no comments needed on this please :))

The administrator can add an article to the system; thats easy enough. But my idea is that i have found there to be minimal formatting for the text to be submitted:
i.e.
Admin submits:
"Hello
World"

Article Shows:
"Hello
World"

This is fine enough, though i would like to have formatting options; similar to those used in this thread submit; i.e. Bold, Italics... Font etc. The way which i would like it to happen is

The admin would click on a button (say Bold) and the script would insert tags for this (<b>Bold Txt here</b>) in just a normal html format, nothing like vB Code as the only person that can create articles will be the admin (so no secure formatting code this this is needed).

If anyone could just get me started on how to create this, or if there are any free examples of this idea that they could point me toward i would appreciate it!

Thanks

violent j
04-29-2004, 08:46 AM
welcome to the forum!

this should work in IE browsers:

<html>
<head>
<title>blaat</title>
<script type="text/javascript">
function saveCurRng() {
curRng = document.selection.createRange().duplicate();
}
function surround(btag, etag){
if (curRng) {
document.editform.article.focus();
curRng.text= btag + curRng.text + etag;
return false;
}
}
</script>
</head>

<body>
<form name="editform">
<textarea rows=5 cols=40 name="article" onKeyup="saveCurRng()" onMouseup="saveCurRng()"></textarea>
</form>
<a href="#" onclick="return surround('<b>', '</b>');">bold</a><br>
<a href="#" onclick="return surround('<i>', '</i>');">italic</a>
</body>
</html>

grtz

Fang
04-29-2004, 08:50 AM
plenty on this forum (http://forums.webdeveloper.com/search.php?s=&action=showresults&searchid=232748&sortby=lastpost&sortorder=descending)
or full app at BlueShoes (http://www.blueshoes.org/en/javascript/editor/)

FarFlungFish
04-30-2004, 04:48 AM
Thanks for the reply;
i just don't know enough about javascript or any other scripting language like to be able to create that kind of stuff.

Ill use the code you gave me and adjust it accordingly.

Also ill check out the links, thanks!

Hope to see you all around on the forums! ;)