Wrox Programmer Forums
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 5th, 2004, 08:36 PM
Authorized User
 
Join Date: Oct 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default Please Help. Urgent!!!

Actually i want to add a function that can save all the html code from wysiwyg (what you see is what you get) Editor. And the code needed some transformation tag from <> to []. Is there anyway to do this? All in javascript. Thanks a lot. ;)

 
Old August 6th, 2004, 03:12 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Tan Soo Loon,

This function will convert your tags, just pass it the html...

Code:
function ConvertTags(pHtml){
    return pHtml.replace(/<([^>]*)>/g, "[$1]"); 
}
BTW, when posting in the future, could you give your topics a suitable title please e.g. "replace html tags" & not "urgent", that way people searching the forum in the future will be able to see whether or not a topic might help them (plus IMHO putting "urgent" as a subject is unlikely to reduce response times).

Kind regards,

Chris

 
Old August 9th, 2004, 02:05 AM
Authorized User
 
Join Date: Oct 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Chris. You help me a lot. :)

 
Old August 9th, 2004, 02:08 AM
Authorized User
 
Join Date: Oct 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Chris,
    Do you know how to convert back tags from [] to <>?
Thank you very much.

 
Old August 9th, 2004, 03:07 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Tan Su Loon,

This should do the trick...

Code:
function RevertTags(pHtml){
    return pHtml.replace(/\[([^\]]*)\]/g, "<$1>"); 
}
If you're going to be doing a lot of replacing of characters in strings, it might be a good idea to check out regular expressions, they may seem confusing at first, but once you get used to them they are enormously powerful.

Cheers,

Chris

 
Old August 9th, 2004, 04:20 AM
Authorized User
 
Join Date: Oct 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Okie. Thanks a lot.

 
Old August 10th, 2004, 04:29 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Cross-post with: http://p2p.wrox.com/topic.asp?TOPIC_ID=17299
Please direct further replies there.

Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail





Similar Threads
Thread Thread Starter Forum Replies Last Post
urgent deb_kareng ASP.NET 2.0 Professional 1 August 13th, 2007 07:29 AM
it's urgent deb_kareng ASP.NET 2.0 Professional 3 August 7th, 2007 07:40 AM
urgent help yash_coolbuddy_forindia BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 1 May 7th, 2007 08:40 AM
urgent???????????? nsr35 Beginning VB 6 1 October 3rd, 2005 10:57 AM
urgent ??????????????? nsr35 Pro VB Databases 0 October 3rd, 2005 04:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.