Print Page | Close Window

Format text on a submit form. Bold etc.

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Web Design Discussion
Forum Description: Discussion on web design and development subjects.
URL: https://forums.webwiz.net/forum_posts.asp?TID=16715
Printed Date: 28 March 2026 at 6:02am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Format text on a submit form. Bold etc.
Posted By: sccs
Subject: Format text on a submit form. Bold etc.
Date Posted: 27 September 2005 at 9:28am
I have created a form for Admin users to add news items to our website. What I would like to do is to let the user change the font, make it bold etc. Just like the one on this form.
How easy is it and how is it done?
Thanks
Andy



Replies:
Posted By: ub3rl337ch3ch
Date Posted: 27 September 2005 at 8:18pm
find out the tags for what you want to do (eg <b></b> for bold) then set up a button so that it  runs a js function:
 
document.form.field.value = document.form.field.value + '<b>'
 
which will give you the content of the textarea plus the opening bold tag. you'd need to have some way to tell whether the tag is open or not, so you know whether to close or open it. There's probably some nice clean way to do this, but the simplest way i can think of is to have a hidden field (name="boldtag") that your js function sets the value of to either open or close... something like:
 
function boldtags(){
if (document.form.boldtag.value == 'open'){
document.form.boldtag.value = 'closed'
document.form.textarea1.value = document.form.textarea1.value + '</b>'
}else{
document.form.boldtag.value = 'open'
document.form.textarea1.value = document.form.textarea1.value + '<b>'
}}
 
on the downside, you have to have a function for each type of change that you want to make.
 
then there's the fact that that function's only theoretical, and i've never used it... Smile



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net