Jump to content

brady123

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

brady123's Achievements

Member

Member (2/5)

0

Reputation

  1. I am trying to update the text in a span with a date (which is working fine), but I also want to format that date before it is updated in the span. For example, in the text area I input a date (format: YYYY-MM-DD HH:MM:SS), and I'd like to output between the span tags M-D-YYYY. Does that make sense? I'm totally lost here and hoping someone can help me out. Here is the javascript. function show_post_date() { var ele = document.getElementById("post_date"); var text = document.getElementById("new_post_date"); // Get the date value, then format it var formatted_date = ele.value; // THIS IS WHAT I'VE TRIED, BUT NOTHING IS UPDATED INTO THE SPAN IF I INCLUDE THIS var curr_date = formatted_date.getDate(); var curr_month = formatted_date.getMonth(); var curr_year = formatted_date.getFullYear(); formatted_date = curr_date + "-" + curr_month + "-" + curr_year; // END SECTION OF WHAT I'VE TRIED if(ele.value != "") { text.innerHTML = formatted_date; } } Here is the element When: <span id='new_post_date' style='font-weight:bold;'></span> <input type="text" name="post_date" id="post_date" value="" onChange='show_post_date()' />
  2. Ah, something so simple, removing that darn flag. Thank you VERY much! You're a genius!!
  3. Sorry, here is a more clear explanation of what I am trying to do. Because I'm trying to use code inside code, It messes it up, so I'll have to leave a space between. Say I have the following code BEFORE parsing: [ code] Here is some code [ /code] Here is some text outside of the first code block. [ code] Here is a second block of code. [ /code] And the output that I'm getting is: <code> Here is some code [ /code] Here is some text outside of the first code block. [ code] Here is a second block of code. </code> Does that make sense? It's parsing the opening tag from the first code section, and the closing tag of the second code section. See how I am able to use the CODE section twice in this current post? I can't get that to work on my site. Thanks.
  4. For something like this: <?php echo "here's some code"; ?> Now I will explain more about this next section... <?php // next part ?> My code is wrapping it all in one <code> section, using the open tag from the first one, and the close tag from the second.
  5. I'm creating a custom BBCode for a code area, much like this site has. My problem is, if I use it twice on one page, the regex will take the opening tag of the first usage, and the closing tag of the second usage. I've played with it forever and can't figure it out. Any ideas on how I can make it stick with the first open/first close, etc? Some type of for each loop? I'm completely stuck and lost. Thanks! Here's my code I'm using... $str = preg_replace("/\[code\](.*?)\[\/code\]/esiU", "'<span style=\"font-size:9px;\">Code:</span><br /><div class=\"code\">'.stripslashes(htmlspecialchars('\\1')).'<br /></div>'", $str);
  6. Works perfect! Does the .ready part make it run when the page is fully loaded? By the way, your personal site is very nice! Did you write it all from scratch, or are you using some CMS?
  7. Sorry, I'm not at all familiar with jQuery - here's the entire code that I can't get working...thanks for your help! <script language='javascript'> window.onload=hider; function hider() { $(document).ready(function(){ $(".loaders").hide(); }); } </script> <div class='loaders'>Hide me when page is done loading.</div> <div class='loaders'>Hide me when page is done loading.</div> <div class='loaders'>Hide me when page is done loading.</div> <div class='loaders'>Hide me when page is done loading.</div>
  8. Hmm, I can't seem to get it to run on its own. I'm trying to make it hide them all when the page is done loading. This is what I have using your code, but can't get it working: window.onload=doneload; function doneload() { $(".loaders").hide(); } <div class='loaders'>Hide me when page is done loading.</div> <div class='loaders'>Hide me when page is done loading.</div> <div class='loaders'>Hide me when page is done loading.</div> <div class='loaders'>Hide me when page is done loading.</div>
  9. I'm trying to figure out how to cycle through all divs on a page with an id of "loader", and hide them. If I just list the first hide element on my JS below, it only hides the first div with that id. How can I cycle through all divs and hide all of them that have that id? Currently I just list them separately and name them separately... function doneload() { document.getElementById("loader").style.display = "none"; document.getElementById("loader2").style.display = "none"; document.getElementById("loader3").style.display = "none"; document.getElementById("loader4").style.display = "none"; }
  10. Dug in and figured it out...whew. For any poor souls out there: Make sure to do this AFTER the nl2br function. $str = preg_replace("/\[nobr\](.*?)\[\/nobr\]/esiU", "stripslashes(preg_replace('/<br(\s)?(?(1)\/)>/i', '', '\\1'))", $str);
  11. In your second set of code, you don't have "mysql" written out correctly, you're missing the "y". Is that it?
  12. I currently have some custom tags, similar to BBCode, to be used for comments on my site. I'm trying to create a [nobr] tag (note: I know the no break tag will work in many major browsers, but it's deprecated, so I'm trying to be compliant) to remove all line breaks between the opening and closing tag. The idea is that if I encounter the [nobr] tag, I need to remove all line breaks between the opening and closing tags. Here's the best I could come up with, but it doesn't work. I can't think of anything else! Can anyone shed some light and help me out. I could be way off here... Note: the new part I'm working on is where you see the before, during, after. The other part of the function is for reference of what I'm working with thus far. function BbToHtml($str) { $pattern = array ( "/\[b\](.+)\[\/b\]/Usi", "/\[i\](.+)\[\/i\]/Usi", "/\[u\](.+)\[\/u\]/Usi", "/\[color=(\#[0-9A-F]{6}|[a-z]+)\](.*)\[\/color\]/Usi", "/\[size=(.*)\](.*)\[\/size\]/Usi", "/\[img=(.*)\](.*)\[\/img\]/Usi", "/\[url=(.*)\](.+)\[\/url\]/Usi", ); $replace = array ( "<strong>\\1</strong>", "<em>\\1</em>", "<u>\\1</u>", "<span style=\"color:\\1\">\\2</span>", "<img src='\\1' alt='\\2' border=\"0\"/>", "<a href='\\1' target='_new'>\\2</a>", ); $before=preg_replace("(.*)/\[nobr\](.*)\[\/nobr](.*)/Usie", "\\1", $str); $during=preg_replace("(.*)/\[nobr\](.*)\[\/nobr](.*)/Usie", "\\2", $str); $after=preg_replace("(.*)/\[nobr\](.*)\[\/nobr](.*)/Usie", "\\3", $str); if($during != "") { $during=str_replace("\r\n","",$during); $str=$before.$during.$after; } $str=nl2br($str); $str = preg_replace($pattern,$replace,$str); return $str; }
  13. The snippet of the function I'm showing is part of a larger function, containing much more, which is why I'm using the str_replace for breaks. I'm trying to remove breaks though, not create them.
  14. I currently have some custom tags, similar to BBCode, to be used for comments on my site. I'm trying to create a [nobr] tag (note: I know the no break tag will work in many major browsers, but it's deprecated, so I'm trying to be compliant). The idea is that if I encounter the [nobr] tag, I need to remove all line breaks. Here's the best I can do, but it's not working as I had hoped. Here's what I currently use to replace line breaks with a break tag. $str=str_replace("\r\n","<br>",$str); Here's my attempt at introducing this new tag. function BbToHtml($str) { $before=preg_replace("/(.+)\[nobr\](.+)\[\/nobr\](.+)/Usi","\\1",$str); $during=preg_replace("/(.+)\[nobr\](.+)\[\/nobr\](.+)/Usi","\\2",$str); $after=preg_replace("/(.+)\[nobr\](.+)\[\/nobr\](.+)/Usi","\\3",$str); $during=str_replace("\r\n","",$during); if($during != "") { // If the [nobr] tag was found, go with the new string. $str = $before.$during.$after; } else { // If the [nobr] tag was not found, go ahead like normal. $str=str_replace("\r\n","<br>",$str); } return $str; I can't get that working. Any ideas on how to fix that, or a completely alternate method of doing it? Thank you!
  15. Assuming I'm fine with it showing, do you know why it's it working?
×
×
  • 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.