CrazeD Posted March 4, 2008 Share Posted March 4, 2008 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. Quote Link to comment Share on other sites More sharing options...
CrazeD Posted March 5, 2008 Author Share Posted March 5, 2008 Bump Quote Link to comment Share on other sites More sharing options...
haku Posted March 5, 2008 Share Posted March 5, 2008 use these two functions: quote.replace("[ quote]", "") quote.replace("[ /quote]", "") insert them in your code before the var newtext line. Quote Link to comment Share on other sites More sharing options...
CrazeD Posted March 5, 2008 Author Share Posted March 5, 2008 I've tried that, it doesn't do anything. Quote Link to comment Share on other sites More sharing options...
fenway Posted March 5, 2008 Share Posted March 5, 2008 I've tried that, it doesn't do anything. You have to assign it back to the quote variable... Quote Link to comment Share on other sites More sharing options...
CrazeD Posted March 5, 2008 Author Share Posted March 5, 2008 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. Quote Link to comment Share on other sites More sharing options...
CrazeD Posted March 5, 2008 Author Share Posted March 5, 2008 Nevermind, I got it sorted. Quote Link to comment Share on other sites More sharing options...
haku Posted March 5, 2008 Share Posted March 5, 2008 How did you end up doing it? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.