Misc Links
Forum Archive
News Archive
File DB
 

Ads
 

Advertisement
Age of Valor - Ultima Online Free Shard
AoS/SE/ML/Custom - advanced code, dedicated staff, peerless bosses, non overpowered customs + much much more
 

Latest Forum Topics
New Bathroom Fan I Bought
Posted by Red Squirrel
on Sep 06 2010, 9:08:47 pm

Duke Nukem Forever
Posted by Red Squirrel
on Sep 04 2010, 1:28:13 am

Dr. Santa Claus?
Posted by Red Squirrel
on Sep 04 2010, 5:12:17 pm

Vmware Shifts Pricing Strategy
Posted by Red Squirrel
on Sep 02 2010, 7:09:04 pm

Badass Chipmunk
Posted by Triple6_wild
on Sep 01 2010, 1:06:15 am

 



Send spam to: website@xeonlive.com nick@xeonlive.com georgiapeach1241@aol.com
BBcode editor: Javascript
Client Side Scripting
By Jonathan Street


Ok, lets sort through all that html.



The start is straightforward, the only two interesting parts to this section are the references to an external style sheet and an external javascript file. I'll look at those later.



This is the start of our form and also the opening of the table that will organise it. When the form is submitted the data is being sent by the post method to the file bbcode.php. Before the form is sent though a javascript function, checkForm, is run. I'll be discussing that later on. The first thing requested from the user is a subject. The class exists so that all the text areas can be formatted later on with css.



We're now getting into some of the functionality of this editor. As you may be able to guess we're adding smilies to our users post. Again a javascript function is called, smilie, clicking on a smilie will automatically append the relevant code onto the end of the document.

I'm storing these smilies at the bottom of some folders but you can of course store them anywhere. If you want some sample smilies then right-click and go to 'save image as' on the smilies below.

smile big grin razz



This is busy! Essentially though it's just the same thing repeated several times with different variables.



Clicking this button passes variables for the bold tags to the tag function. The same is repeated for all the other tags. Again we assign a class to aid design later on and the helpline is present for the first time. Again I'll go into this function in depth when I come to the javascript file.



Here we have the options for text color and size. A new function, font, appears. For font color the options listed will appear in their actual colors thanks to the local style attributes. The 16 pre-defined colors are given as options.

Quite often text size is given as absolute values, 12px for example. I've slowly come to the conclusion that relative values are better and these are what I've used here. I currently use the firefox browser and if I visit a website where the text is too small (as it frequently is in the early hours of the morning) all I need to do is click Ctrl and + and it will increase in size. Simple. It's not so simple in Internet Explorer however where the default setup means you need to go to a menu option to increase the text size and even then it will only work with relative text sizes. Hence why I decided from now on only to use relative text sizes.



We have two things going on here. We're creating the line where the helpline function will display its output, namely helpbox. It's readonly so the user can't type into the box but it doesn't prevent the javascript doing its thing. We'll also later disguise it so the user wont even realise it's an input box.

There is also the main area where the user will add their content. It's a simple textarea.



This is the end of the form. There are three buttons here. The user can post their message straight away, preview their post or start over. For start over a javascript function is called. It simply gives the user a second chance before the form is actually wiped.

That's it for the html. Now lets give it a bit of style with css.


Next Page
spacer
54930 Hits Pages: [1] [2] [3] [4] [5] [6] 29 Comments
spacer


Latest comments (newest first)
Posted by we_undertaker on May 05th 2008 (02:00)
i looke at http://www.iceteks.com/articles.php/javascript/1
i really like this text editor

but i dont know how to use it, cos i just new in PHP
could you please tell me how to use that with SQL , cos i want to have this text editor.

and in your html code :
<form action="bbcode.php" method="post" name="editform" onsubmit="return checkForm(this)">
i also dont know how to create bbcode.php , to run the form ...

please , please help me, i really need it
Thank you, Thank you so much

spacer
Posted by AdRock on August 08th 2007 (04:40)
I have followed the article and have noticed there are errors that I don't know how to fix.

I have used the exact code as provided in the article.

The first error I was able to fix which was a backslash in <textarea> which was missing but this is the main error.

When I type a word in the text area and I want to do some formatting such as bold or italic, th ewhole word is not highlighted with the start and end tags such as some words (supposed to be the [b] tags in there) but instead it just does some words[b].

One other question which is probably really stupid but is the second article the php file which is called when you preview what you have written?

spacer
Posted by Red Squirrel on August 08th 2007 (12:52)
Force be with you, always!
spacer
Posted by AltaGid on August 08th 2007 (13:01)
Hello! Help solve the problem.
Very often try to enter the forum, but says that the password is not correct.
Regrettably use of remembering. Give like to be?
Thank you!

spacer
Posted by sgreeny12 on April 04th 2007 (12:23)
Hey great tutorial. Really works except I have 1 question if you dont mind. I want to add an align right button similar to the one on devshed forms where the image is the classic microsoft alight right button. When I click on the bottom it automatically submits the script. Does anyone have any fixes? Thanks

I could make it into a smile but i wouldnt know how to have it give the close option. Can someone help me with that. Thanks


The first 3 work because they arnt images. The 4th which is the image doesnt work.
CODE
               <input type="button" src="images/icons/justifyleft.gif" class="button" value="left" name="left" onclick="java-script tag('left', '[left]', 'left*', '[/left]', 'left', 'left');"

onMouseOver="helpline('left')" />
               <input type="button" src="images/icons/justifycenter.gif" class="button" value="center" name="center" onclick="java-script tag('center', '[center]', 'center*',

'[/center]', 'center', 'center');" onMouseOver="helpline('center')" />
               <input type="button" src="images/icons/justifyright.gif" class="button" value="right" name="right" onclick="java-script tag('right', '[right]', 'right*', '[/right]',

'right', 'right');" onMouseOver="helpline('right')" />

               <input type="image" src="images/icons/justifyright.gif" class="button" value="right" name="right" onclick="java-script tag('right', '[right]', 'right*', '[/right]',

'right', 'right');" onMouseOver="helpline('right')" />

spacer
View all comments
Post comment

Age of Valor Ultima Online Server

Top Articles Latest Articles
- What are .bin files for? (592877 reads)
- Big Brother and Ndisuio.sys (143128 reads)
- PSP User's Guide (127762 reads)
- Text searching in linux with grep (115254 reads)
- SPFDisk (Special Fdisk) Partition Manager (101260 reads)
- Dynamic Forum Signatures (version 2) (4689 reads)
- Successfully Hacking your iPhone or iTouch (14355 reads)
- Ultima Online Newbie Guide (25095 reads)
- BBcode editor: PHP - The sensible approach (17927 reads)
- The Hitch Hikers guide to "the mouse" (15308 reads)
corner image

This site best viewed in a W3C standard browser at 800*600 or higher
Site design by Red Squirrel | Contact
© Copyright 2010 Ryan Auclair/IceTeks, All rights reserved