This is a discussion on "Sending HTML only on Submit." within the JavaScript Forum section. This forum, and the thread "Sending HTML only on Submit. are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Sending HTML only on Submit.
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Sending HTML only on Submit.
Here's my question. Let's say I build an editor based on the Idea of Monie and Spinal.
<blockquote id="quote" class="ffs">quote:<hr height="1" noshade="noshade" id="quote" />I'm not good at these things but i'll explain monie's code... THE IDEA: the textRange object lets you rerieve and change text within an element. USES: "document.selection" points to the current selection on the document (duh!) I made a small example so you can try it out yourself. save this onto a htm file and run it: <SCRIPT> function MakeBold(){ // find selection r = document.selection.createRange(); // exit function if no selection has been made if(r==null){ return; } // replace selection by itself, surrounded by the "[b]" tag r.pasteHTML("" +r.htmlText+ ""); } </SCRIPT> <INPUT TYPE=button value="Make Selection Bold" onMouseDown="MakeBold();"> text and more text and more text and more text and more text and more text and more text and more text and more text and more text and more text and more text and more text and more text and more text and more text and more text and more text and more text and more text and more text and more text and more text and more text and more text and more text and more text and more text and more text and more text and more </BODY> 1 . make a selection 2 . click the "Make Selection Bold" button 3 . that will trigger a function wi=hich will: 3 a) find the selection in the body of the document 3 b) retrieve the selected text 3 c) replace it by the same selected text sorrounded by the "[b]" tag <hr height="1" noshade="noshade" id="quote" /></blockquote id="quote"> How would I go about making it where when the user clicked on "Submit" it sends the HTML only and not the script? I think if I can get this to work it would be great for my users who don't understand anything about HTML. |
|
|
|
||||
|
simple,
once you've updated the textRange's html to show the result of the operation, use the same textRange to retrive the HTML code and save the it onto a hidden textarea, then submit the textarea... i dont have time now but I'll write an example later...
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
|
|
||||
|
I would not advice you designing your own HTML editor for the following reasons:
1. there's free stuff out there. many very talented programmers (God bless the bastards) spend months or even years developing the most sweet pieces of coding you ever seen and let you use at at will. I gave up my own editor when I found htmlArea (http://www.interactivetools.com/products/htmlarea/) 2. having made the point above, you'll be wasiting your time trying to design something that will match the quality of the above, so unless you're simply trying to learn a few techniques, don't go all the way. by all means try and re-create the software in your own way, practice and learn from the code, but anyone is better off taking advantage of the free software available. 3. I forgot wat my third point was... |
|
||||
|
dat was me ^^^^
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
|
|
||||
|
[img]images/spinalbrain.gif[/img]
__________________
Rob - SEO Specialist Owner & Founder of Webforumz.com I am currently unavailable for private work
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
||||
|
OOOOOOOOOOOOOOHHHHHHHHHHHHHHHH....................
THAT'S GETTING PERSONAL.... but I like it! nice chart!
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
|
|
||||
|
__________________
Rob - SEO Specialist Owner & Founder of Webforumz.com I am currently unavailable for private work
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
|||
|
I think Rob has WAAAY too much time on his hands!
|
|
||||
|
yeah, me too!
I;d never do have anytime to aste on that....
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
|
|
||||
|
I took me 3 minutes.... lol
__________________
Rob - SEO Specialist Owner & Founder of Webforumz.com I am currently unavailable for private work
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
![]() |
| Tags |
| sending, html, submit |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Html button sending data to flash movie..how??? | webworks | Flash & Multimedia Forum | 2 | Sep 23rd, 2007 16:13 |
| Need help sending HTML message in PHP. | annawilsonz | PHP Forum | 0 | Sep 14th, 2007 06:31 |
| submit many forms - auto submit the same form many times | divs | JavaScript Forum | 0 | May 24th, 2007 10:10 |
| HTML forms (format after submit) | dannozza | Web Page Design | 1 | May 11th, 2007 14:35 |
| problem with images when sending html page by mail | juanb007 | Web Page Design | 4 | Apr 29th, 2007 03:25 |