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. Link to comment https://forums.phpfreaks.com/topic/94348-need-to-remove-dynamic-content-from-string/ Share on other sites More sharing options...
CrazeD Posted March 5, 2008 Author Share Posted March 5, 2008 Bump Link to comment https://forums.phpfreaks.com/topic/94348-need-to-remove-dynamic-content-from-string/#findComment-483459 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. Link to comment https://forums.phpfreaks.com/topic/94348-need-to-remove-dynamic-content-from-string/#findComment-483483 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. Link to comment https://forums.phpfreaks.com/topic/94348-need-to-remove-dynamic-content-from-string/#findComment-483519 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... Link to comment https://forums.phpfreaks.com/topic/94348-need-to-remove-dynamic-content-from-string/#findComment-483536 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. Link to comment https://forums.phpfreaks.com/topic/94348-need-to-remove-dynamic-content-from-string/#findComment-483541 Share on other sites More sharing options...
CrazeD Posted March 5, 2008 Author Share Posted March 5, 2008 Nevermind, I got it sorted. Link to comment https://forums.phpfreaks.com/topic/94348-need-to-remove-dynamic-content-from-string/#findComment-483543 Share on other sites More sharing options...
haku Posted March 5, 2008 Share Posted March 5, 2008 How did you end up doing it? Link to comment https://forums.phpfreaks.com/topic/94348-need-to-remove-dynamic-content-from-string/#findComment-483585 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.