Jump to content

Need to remove dynamic content from string


CrazeD

Recommended Posts

I'm making a comments system and I'm adding a BBCode quote system.

 

It works great for one quote, but if you try to quote a quote it messes up. I would rather there only be one quote. So, I want a function to remove [ quote]quoted message[/ quote] when it adds the quote tags.

 

This is hard to explain, I hope you get what I mean.

 

Here's is my function to add the quote tags in the first place:

 

function addQuote(user,quote) {
    var newtext ="[ quote="+user+"]"+quote+"[/ quote]";
    document.post.post_body.value += newtext;
}

And my usage:

 

<a href="javascript:addQuote(\''.$userRow['username'].'\',\''.$cRow['comments_body'].'\');">Quote</a

Works great. But, like I said, I need the function to strip anything between the quote tags before it's quoted... if that makes any sense at all....

 

I was thinking I'd have to use regex, but I'm only a newbie with Javascript and that looks intimidating. I'm good at modifying existing code, so if anyone use a tutorial that glances at what I'm trying to do that'd be great too.

 

Thanks.

 

NOTE: I put spaces in the [ quote] tags above so it doesn't mess up the forum.

Yeah...all it does is delete the actual quote tags. I need what's inside the quote tags to be deleted as well.

 

When I press the quote button, my function copies the contents of that post to the comment box. If is already a quoted message in that post, I want it to be removed before the text is copied.

 

Sorry if I didn't explain it well.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.