Sending HTML only on Submit.

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.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 18th, 2004, 03:35
Reputable Member
Join Date: Sep 2004
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
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.

  #2 (permalink)  
Old Oct 19th, 2004, 11:22
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
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)
  #3 (permalink)  
Old Oct 19th, 2004, 16:12
Anonymous User
Guest
Posts: n/a
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...
  #4 (permalink)  
Old Oct 19th, 2004, 16:15
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
dat was me ^^^^
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
  #5 (permalink)  
Old Oct 19th, 2004, 18:28
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
[img]images/spinalbrain.gif[/img]
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
  #6 (permalink)  
Old Oct 19th, 2004, 18:38
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
OOOOOOOOOOOOOOHHHHHHHHHHHHHHHH....................
THAT'S GETTING PERSONAL....


but I like it! nice chart!
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
  #7 (permalink)  
Old Oct 19th, 2004, 18:52
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
  #8 (permalink)  
Old Oct 19th, 2004, 19:57
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
I think Rob has WAAAY too much time on his hands!
  #9 (permalink)  
Old Oct 19th, 2004, 19:58
benbacardi's Avatar
Highly Reputable Member
Join Date: Feb 2004
Location: United Kingdom
Age: 20
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to benbacardi Send a message via Skype™ to benbacardi
i agree!
  #10 (permalink)  
Old Oct 20th, 2004, 08:40
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
yeah, me too!

I;d never do have anytime to aste on that....
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
  #11 (permalink)  
Old Oct 20th, 2004, 09:09
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
I took me 3 minutes.... lol
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Closed Thread

Tags
sending, html, submit

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 09:23.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43