Jump to content

Frank P

  • Posts

  • Joined

  • Last visited

Everything posted by Frank P

  1. man5, The Login · Signup · About · Lola's Dress · Create a product · Find Products · News Feed. Recent Products, are they h2s of separate pages, or all on one page? And can you post the HTML of your navigation menu (CSS not necessary)?
  2. If $data includes user-provided data one should indeed be careful with echoing PHP data in a JS context. But the syntax error argument is a weak one, and no reason to "not, I repeat, not" echo them as such. That would limit the options way too much. Just keep a keen eye on the syntax. And in case of problems, just use a debugger, which generally will point out the line with the (syntax) error.
  3. It's not easy, and it's a native-JS tutorial, but it is described here. On the other hand, it uses cookies, which would be easier than the PHP method.
  4. You could start with clarifying the question. What do you mean with "I would put it in html, but I use javascript to clear the page"? Are you clearing all of the HTML with Javascript? Can you tell us something more about that, because that sounds really odd? And have you searched the internet with "javascript document.write" and if so, what remained unclear after that?
  5. Josh, There are gentler ways to win an argument than bullying ("I don't believe you have much experience dealing with corporations, and possibly even clients in general"). Such as with valid arguments that have weight. Which I don't see in your reply. First of all, I'm working on IT projects that are probably way out of your league. The fact that I don't have time to make websites for small business and private parties doesn't mean that I wouldn't know what I'm talking about. The other night I solved a layout problem on Stack Overflow that nobody else knew how to solve. A question that was posted by one of the SO moderators, and that got a bunch of up-votes and favorite-question stars in no-time. Also, simple logical reasoning disproves your basic point, even if I would be a novice. Nowadays, there are only two kinds of users who still have IE6/7. The first kind is the people who still have a Windows 95 computer. I don't think any webdev in their right mind would wanna code for them. The second kind is the employees of large companies with XP computers, obliged to use it for their intranet sites. Not much wrong with that, but they won't use that same IE6/7 for the internet sites they visit. Simply because they've learned that those sites are not functional anymore with such an old browser. They will get alerts all the time, and will use FF or Chrome, which they have will have installed on their computer as well. Those large companies have their own IT staff, making their own intranet websites. I don't think many PHP Freaks webdev-visitors will be asked by such companies to make a site for them. In fact, I would think the number is zero. Apart from you, maybe. Furthermore, the (American) stats on http://gs.statcounter.com/#browser_version-US-monthly-201305-201405 show that even IE7 has left the building. And which corporations are you referring to that have sites that need IE6/7 to be functional and esthetically appealing? Unless you have a time machine, I don't think there are such corporations anymore. N=0, again. Nonetheless, I wanna make friends with you. How about if I write a tutorial for PHP Freaks, explaining the basics of modern Ajax, including the pitfalls regarding the implementation of the responseText, which there still are a number of? I'll do it for free. Just think about it. But even if you reject this offer, you still have to delete this whole thread. Because what you are stating in your original post translates to "If you don't use layout tables, don't come asking here for advice" on the CSS section of PHP Freaks. Time to upgrade, Josh.
  6. Josh, I don't believe for a minute that most webmasters still strive to make sites suited for IE<8. And those few who still do should think again. Users with IE<8 can easily upgrade to 8, even have to actively stop Windows (XP) Update from doing so. IE8, and all later IEs, default to Compatibility Mode/View (= IE7) in case of intranet sites, so there is no reason whatsoever for them not to upgrade. And for the 50 users around the whole world who cannot because their company intranet site only functions well in IE6, there is always FF and Chrome. Even their latest versions run perfectly well on Windows XP. Which they already have installed anyway, because plenty of internet sites do not function in IE6/7 anymore. So, a simple alert for IE<8 users suffices. Keep it simple. And keep it economical for the clients, because making a site suited for IE<8 probably doubles the cost, and/or hampers the possibilities severely. Most certainly when it comes to IE6. With regards to the implementation of the responseText, I guess you are referring to the innerHTML? If so, that makes no difference. jQuery cannot make IE<10 insert/modify <option>s in a <select> either (the famous DOM child update problem that IE<10 has with nodes that standard have children). And there is a simple non-jQuery solution for that: put the <select> in a <span> or <div>, and update the whole <select>. Also, using outerHTML works as well, also in IE8. Still no need for jQuery, therefore.
  7. Unless the jQuery is also used to accomplish matters that cannot be accomplished with native JS, or that would otherwise require extensive or complicated coding, I see no reason to use jQuery for Ajax calls. IE8+ and all other browsers support the standard XMLHttpRequest(). And what is so difficult about this: function updateContent(container) { var ajaxRequest = new XMLHttpRequest(); ajaxRequest.onreadystatechange = function() { if ((ajaxRequest.readyState == 4) && (ajaxRequest.status == 200)) { document.getElementById(container).innerHTML = ajaxRequest.responseText; } } ajaxRequest.open("GET","new_content_file.php",true); ajaxRequest.send(); } See also http://toddmotto.com/is-it-time-to-drop-jquery-essentials-to-learning-javascript-from-a-jquery-background/.
  8. Your code seems OK. The only thing I can think of is that iOS has problems with the try & catch primer function. And why would you wanna use that anyway? IE8+ and all other browsers support XMLHttpRequest(), and coding for IE<8 is a waste of time, if you ask me. IE7 users can easily upgrade to 8, and IE6 has left the building.
  9. That shouldn't be a matter of Wordpress, but of correct CSS and browser support. I don't like Wordpress, but this is likely to be caused by the author or the browser.
  10. Thanks again, Psycho. I will correct the insufficiencies you described. And I found out that a button with an undeclared type attribute automatically gets the submit function. See http://dev.w3.org/html5/markup/button.html.
  11. @ Psycho: OK, thanks anyway. @ cyberRobot: I had already tried that, but that didn't work. This however does: function unCheckRadios(name,itemId,buttonId) { var radios = document.getElementsByName(name); for (var n = 0; n < radios.length; n++) { radios[n].checked = false; document.getElementById(itemId).style.backgroundColor = ''; document.getElementById(buttonId).style.display = 'none'; } return false; // to prevent premature submitting of the form } plus <button id="A1a-button" onclick="return unCheckRadios('A1a','A1a-row','A1a-button')">De-check</button>
  12. Hey Psycho, Thanks for responding. But why is the form submitted then? And why is it not submitted if I have the table row displayed from the start?
  13. I have the weirdest thing with this code: <!DOCTYPE HTML> <html> <head> <style type="text/css"> table { width: 100%; border: 1px solid black; border-collapse: collapse; } td { border: 1px solid black; } button { height: 20px; display: none; } a { text-decoration: underline; } .click-text { color: darkorange; } .click-text:hover { color: blue; cursor: pointer; } .elucidation-row { display: none; } .score-cell, .uncheck-cell { width: 100px; } </style> <script> function showAllItems() { var elRows = document.getElementsByClassName('elucidation-row'); for (var p=0; p<elRows.length; p++) { elRows[p].style.display = 'table-row'; } } function highlightItem(itemId,buttonId) { document.getElementById(itemId).style.backgroundColor = 'yellow'; document.getElementById(buttonId).style.display = 'inline'; } function unCheckRadios(name) { var radios = document.getElementsByName(name); for (var n=0; n<radios.length; n++) { radios[n].checked = false; } } </script> </head> <body> <form action=""><!-- older IEs do weird things with a table with colspan and a form inside --> <table> <tbody> <tr> <td class="divider-thin" colspan="7"><a class="click-text" id="toggle-all" onclick="showAllItems()">Show all items</a></td> </tr> <tr class="elucidation-row section-A" id="A1a-row"> <td class="item-cell">Item</td> <td class="uncheck-cell"><button id="A1a-button" onclick="unCheckRadios('A1a')">De-check</button></td> <td class="score-cell"><input type="radio" name="A1a" value="1" onclick="highlightItem('A1a-row','A1a-button')"></td> <td class="score-cell"><input type="radio" name="A1a" value="2" onclick="highlightItem('A1a-row','A1a-button')"></td> <td class="score-cell"><input type="radio" name="A1a" value="3" onclick="highlightItem('A1a-row','A1a-button')"></td> <td class="score-cell"><input type="radio" name="A1a" value="4" onclick="highlightItem('A1a-row','A1a-button')"></td> <td class="score-cell"><input type="radio" name="A1a" value="5" onclick="highlightItem('A1a-row','A1a-button')"></td> </tr> </tbody> </table> </form> <p class="elucidation-row">Text line</p> </body> </html> Open it, click 'Show all items', check a radio button, click the appearing 'De-check' button, and see that the whole table row is non-displayed again. It looks as if the unCheckRadios function recalls the executed showAllItems function. Why is that, and how do I solve it?
  14. Frank P

    css nesting

    The right away according to the normal CSS syntax.
  15. Hi there, You wrote: "Windows devices it loads at the bottom of the screen on first load but stays on that part of the page when scrolled." Isn't that what it is supposed to do? Further: "and some androids it jumps around when scrolling." That would be something it should not do. Do you use viewport declarations/settings? If so, could you try what happens without them? I would also need to know which browsers on Android.
  16. Got it! I saw your example and suddenly realized that the + in javascript, with which I primarily work, is not a + but a . in PHP! This is how it works the way I want it to: <?php function makeClass() { if(!isset($_GET['type'])) { $type = 'normal'; } elseif (isset($_GET['type'])) { $type = $_GET['type']; } return $type; } $part_1 = '<!DOCTYPE HTML> <html class="'.makeClass().'"> <head> <meta charset="utf-8"> ' ?> Again, thanks for jumping in so quickly!
  17. You mean like this: <?php function makeClass() { if(!isset($_GET['type'])) { $type = 'normal'; } elseif (isset($_GET['type'])) { $type = $_GET['type']; } return $type; } $part_1 = '<!DOCTYPE HTML> <html class=\'echo $type\'> <head> <meta charset="utf-8"> ' or: <?php function makeClass() { if(!isset($_GET['type'])) { $type = 'normal'; } elseif (isset($_GET['type'])) { $type = $_GET['type']; } return $type; } $part_1 = '<!DOCTYPE HTML> <html class="echo $type"> <head> <meta charset="utf-8"> ' ? Unfortunately, that doesn't work either. In both cases I still get a literal echoing of $part_1 as a result. No class="normal" or class="touch".
  18. Thanks for jumping so quickly! I was mistaking, I got the undefined-variable warning in another configuration. I don't know which one again, because I have tried so many combinations. This is what I get as a result in the above (latter) configuration: a literal echoing of the line: <html class="<?php echo $type; ?>">
  19. Depending on a set value in the URL, the html element should get a class. In this way it works: include-test.php: <?php require("include-test-included.php"); ?> <!DOCTYPE HTML> <html class="<?php echo makeClass(); ?>"> <head> <meta charset="utf-8"> <title>Demo</title> <style> html.normal { background: white; } html.touch { background: red; } </style> </head> <body> </body> </html> include-test-included.php: <?php function makeClass() { if(!isset($_GET['type'])) { $type = 'normal'; } elseif (isset($_GET['type'])) { $type = $_GET['type']; } return $type; } ?> But I would very much like to be able to do it this way, because I have a number of pages, and the head section is already largely PHP-generated: include-test.php: <?php require("include-test-included.php"); ?> <?php echo $part_1 ?> <title>Demo</title> <style> html.normal { background: white; } html.touch { background: red; } </style> </head> <body> </body> </html> include-test-included.php: <?php function makeClass() { if(!isset($_GET['type'])) { $type = 'normal'; } elseif (isset($_GET['type'])) { $type = $_GET['type']; } return $type; } $part_1 = '<!DOCTYPE HTML> <html class="<?php echo $type; ?>"> <head> <meta charset="utf-8"> ' ?> However, this way I get an undefined-variable warning. Which makes sense, because it is outside the function. But how do I get this class variable in the html tag? I have been fiddling for a couple of hours already with backslashes, single/double quotes and echoing the function, but have not found the right way yet. Which is the right way?
  20. No, there isn't. But you have brought up a good point, an argument against certain media queries. Folks should always have a choice which site they want to visit. The problem is that nowadays there are many devices that are a sort of hybrid: something in between a phone and a full-size tablet.
  21. Who do you mean with 'our expert PHP developers', this being your first post?? And why refer to PHP developers anyway, if PHP cannot even make something like this??
  22. In stead of windows.pageYOffset one would better use document.documentElement.scrollTop || document.body.scrollTop. The first is not supported by IE<9.
  23. OK. I moved the whole About section to the bottom of the page. I assume that folks who want to know about me are smart enough to look there. And that is a much better place for the sharing icons, too. Regarding the menu: with 'fixed' I meant fixed to the viewport, not to the page. Some tutorials are really long, in which case I think people would find it handy to not have to scroll all the way back up to go to another page. With respect to including code snippets on the page itself: in this case that is only useful if you also get the HTML. I would have done that if it would have been a tut that people read often. But vertical centering is rarely a question on forums. Much less than the topics of the other tuts. Also, I would think that people will primarily use the tut as a problem solver, which means that they will look up the technique most suited for their problem on the flowchart, look at that source code and hardly look at the rest. I did also change the background of the forums pop-up, but furthermore am going to leave it as it is now. Nonetheless, your feedback has been really valuable. Thanks again!
  • 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.