Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. Instead of trying to pick apart different browser DOM structures, I suggest you instead do something like this: <style type='text/css'> .redBox { border: 1px solid red; margin-bottom: 5px;} .clearBox { border: none; margin-bottom: 5px;} </style> <div id='box1' class='redBox' onclick='makeRed(1)'>something</div> <div id='box2' class='redBox' onclick='makeRed(2)'>something</div> <div id='box3' class='redBox' onclick='makeRed(3)'>something</div> <div id='box4' class='redBox' onclick='makeRed(4)'>something</div> <div id='box5' class='redBox' onclick='makeRed(5)'>something</div> <script type='text/javascript'> function makeRed(val) { var classNode = (navigator.appName.indexOf('Microsoft')>-1)?'className':'class'; var boxes = document.getElementsByTagName('div'); //get all elements with div tag if (boxes) { for (var i = 0; i < boxes.length; i++) { if (boxes[i].getAttribute(classNode)=='redBox') { boxes[i].setAttribute(classNode,'clearBox'); } } } document.getElementById('box'+val).setAttribute(classNode,'redBox'); // } </script> Basically you have two css classes, one that sets the border and one that clears it. And instead of trying to retrieve and look at border values, check and change css classes and let the browser figure out the details. But even then, as you can see in the code, I still have to do it based on browser...welcome to the woes of cross-browser compatibility. I highly suggest you learn and use jQuery or similar js framework, as it super helps in abstracting away the worries of having to do things differently for different browsers.
  2. if (boxes[i].style.border == '1px solid red') { you are checking if style.border is '1px solid red' but that's not how IE stores the border property. Use IE web developer, inspect the element.
  3. problem is not getElementsByTagName it's your style.border condition that is failing. You need to look at how IE's DOM stores css properties.
  4. $str = preg_replace('~@([a-z0-9_]+)~i', '<a href="message.php?member=$1">$1</a>', $str);
  5. Not psychic... 1) post an example string where @USERNAME is actually used 2) explain what characters can appear in USERNAME (only letters? letters and numbers? symbols? spaces? etc...)
  6. I suggest you take on shitty clients so you can be extra specially challenged with trying to find workarounds for things. I can't even begin to tell you how much I've learned over the years due to so-called web devs of clients who without exaggeration, literally fail at even c/p'ing shit.
  7. Jesi was actually one of the first members of PHPFreak Recommended group when PFR was first created, before there was even a Guru group.
  8. I have... HDD: 600gb ram: 6gb graphics: 1gb ram ati radeon 5700 processor: AMD Phenom 9550 Quad-Core Processor (4 CPUs), ~2.2GHz monitors: 2x20" OS: Vista 64 bit home premium I guess my e-peen isn't as big as you guys' but it's more than plenty to get my job done and play some games on something other than lowest settings
  9. I don't have to explain my art to you, Warren.
  10. I made that just for you. Fear my photoshop skillz
  11. I think this should cover hyphens preg_match_all('~Med Given: ((??!-\s*\d{1,2}:\d{1,2} (?:A|P)M|Med Admin Route:|Dosage:|$).)+)(?:\s*-\s*(.*?(?:A|P)M))?(?:\s*Med Admin Route:((??!Dosage:|$).)+))?(?:\s*Dosage:\s*(.*))?~',$content,$matches);
  12. preg_match_all('~Med Given: ((??!-|Med Admin Route:|Dosage:|$).)+)(?:\s*-\s*(.*?(?:A|P)M))?(?:\s*Med Admin Route:((??!Dosage:|$).)+))?(?:\s*Dosage:\s*(.*))?~',$content,$matches);
  13. what about being in different orders? Like... Dosage: xxx Med Admin Route: xxx Med Given: xxx
  14. preg_match_all('~Med Given: ((??!-|$).)+)(?:\s*-\s*(.*?(?:A|P)M))?(?:\s*Med Admin Route:((??!Dosage:|$).)+))?(?:\s*Dosage:\s*(.*))?~',$content,$matches);
  15. // example haystack $content = <<<BLAH Med Given: Versed - 9:50 PM Med Admin Route: Intravenous Dosage: 20.00 MG Med Given: Lidocaine - 9:50 PM Med Admin Route: Intravenous Dosage: 150.00 MG Med Given: Succinylcholine - 9:50 PM Med Admin Route: Intravenous Dosage: 200.00 MG Med Given: Oxygen - 7:23 PM Dosage: 2.00 L/MIN Med Given: Vancomycin Med Given: Fentanyl Med Given: Dopamine Med Given: Dextrose Med Given: Gentamicin BLAH; preg_match_all('~Med Given:\s+([^\s]+)(?:\s+-\s+(.*?(?:A|P)M))?(?:\s+Med Admin Route:\s+([^\s]+))?(?:\s+Dosage:\s+(.*))?~',$content,$matches); array_shift($matches); $c = count($matches[0]); for ($x=0;$x<$c;$x++) { $rows[$x] = array( 'med' => trim($matches[0][$x]), 'time' => trim($matches[1][$x]), 'route' => trim($matches[2][$x]), 'dosage' => trim($matches[3][$x])); } // output echo "<pre>"; print_r($rows); output: Array ( [0] => Array ( [med] => Versed [time] => 9:50 PM [route] => Intravenous [dosage] => 20.00 MG ) [1] => Array ( [med] => Lidocaine [time] => 9:50 PM [route] => Intravenous [dosage] => 150.00 MG ) [2] => Array ( [med] => Succinylcholine [time] => 9:50 PM [route] => Intravenous [dosage] => 200.00 MG ) [3] => Array ( [med] => Oxygen [time] => 7:23 PM [route] => [dosage] => 2.00 L/MIN ) [4] => Array ( [med] => Vancomycin [time] => [route] => [dosage] => ) [5] => Array ( [med] => Fentanyl [time] => [route] => [dosage] => ) [6] => Array ( [med] => Dopamine [time] => [route] => [dosage] => ) [7] => Array ( [med] => Dextrose [time] => [route] => [dosage] => ) [8] => Array ( [med] => Gentamicin [time] => [route] => [dosage] => ) )
  16. So you want to do a splash or preloader screen? ugh, those are so annoying. You should stay away from doing that unless your site really is loading something that takes a good amount of time to load. But if you insist, it would be easier to give it its own page and then redirect to real page when it's done.
  17. I kinda find it odd that the makers/support staff of a CMS would fail to catch this error...anyways...problem is that you are using @ as the regex delimiter but you have it in the middle of the pattern instead of at the end. elseif($moduleinthisgroup[$som_groupmenu][$keyinthisgroup]=="Lien externe" && !preg_match("@modules.php?name=@i", $linkinthisgroup[$som_groupmenu][$keyinthisgroup]) && !preg_match("@((http(s)?)|(ftp(s)?))://".$_SERVER['SERVER_NAME']."/modules.php\?name=@i",$linkinthisgroup[$som_groupmenu][$keyinthisgroup])) {
  18. as in, the whole page? That doesn't really make sense..you're basically asking "How do I wait until the page is loaded, to show the page?"
  19. while (!color.match(/^#[A-Fa-f0-9]{6}$/)) { - you don't need to escape # - you don't need to do #{1} as it is superfluous - hexadecimal numbers only contain letters a-f not a-z - main thing you were missing was start and end of string anchors (^...$) which tells the regex engine that it must start with the # followed by 6 a-f0-9 and then nothing else.
  20. 1) That's javascript, not java. Two totally different things, despite similar names 2) javascript cannot send emails. You have to submit the information (like when user clicks on form submit button) and do it server-side with for instance php's mail() function.
  21. build it from scratch. That's about as customizable as it gets.
  22. /* function based on the following rules: 1) username can have 0 or more of 0-9!@#$%^&*() but it must be preceded by a ` 2) username can have 0 or more letters, case insensitive returns true if valid, false if not */ function validateUsername($username) { // check to see if $username only contains valid chars if(!preg_match('~^[a-z0-9!@#$%^&*()`]+$~i',$username)) return false; // check if ` precedes symbol or number if(!preg_match('~`[0-9!@#$%^&*()]~',$username)) return false; // valide username return true; } // end validateUsername
  23. Okay, you have a link like http://www.yoursite.com/news/search?query=something And you want it to be redirected to http://www.yoursite.com/news/search/query/something Put this in your .htaccess file: .htaccess RewriteEngine on RewriteCond %{QUERY_STRING} ([^=]+)=([^&]*) RewriteRule ^news/search news/search/$1/%2 [R=301]
  24. good luck on your reading on lookarounds...they are one of the hardest parts of regex to grasp In theory they seem easy enough but in practice...lol you will most likely bang your head on the wall many times
×
×
  • 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.