Jump to content

dsonesuk

Members
  • Content count

    9,486
  • Joined

  • Last visited

  • Days Won

    13

Everything posted by dsonesuk

  1. dsonesuk

    How to Prepend Zeros to a Numerical Value

    Number is a wrapper object and specifically deals with numeric or numeric strings. Number.prototype will represent a prototype for Number constructor that is a function (.pad =function(size){...}) to manipulate the object Number i.e (2) value passed to it. So if you create (2) Number object belonging to prototype constructor Number.prototype.pad=function(size){...} (2).pad(3) This will use these object and argument values to initialise this specific constructor (Number.prototype.pad=function(size)) for number manipulation and return the result.
  2. dsonesuk

    How to Prepend Zeros to a Numerical Value

    Its Explained here https://www.w3schools.com/jsref/jsref_prototype_num.asp It deals with creating a new number method, the example you give takes the (2) and uses as number to be converted in the method which is called by the '.pad' part, the parameter of (3), is the max size/length to convert to (number less than 100, three digits), the Number (2) length is tested against size, if less than size it adds a '0' at beginning. Number.prototype.pad = function(size)
  3. dsonesuk

    How to Prepend Zeros to a Numerical Value

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" id="viewport" content="target-densitydpi=high-dpi,initial-scale=1.0"> <title>Document Title</title> </head> <body> <div id="demo"></div> <script> Number.prototype.pad = function(size) { var s = String(this); while (s.length < (size || 2)) { s = "0" + s; } return s; } var demoDiv = document.getElementById("demo"); demoDiv.innerHTML += "<p>" + (2).pad(3) + "</p>"; // => "002" demoDiv.innerHTML += "<p>" + (10).pad(3) + "</p>" // => "010" demoDiv.innerHTML += "<p>" + (100).pad(3) + "</p>" // => "100" </script> </body> </html>
  4. Its just a matter identifying object, transverse down to parent item, object/array using dot.notation and looping through each child item to display its value. <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" id="viewport" content="target-densitydpi=high-dpi,initial-scale=1.0"> <title>Document Title</title> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script> <script> visitor_data = { "lastVisits": [ { "firstVisit": { "prettyDate": "Monday, May 14, 2018", "otherItem": "recent" } }, { "firstVisit": { "prettyDate": "Monday, May 14, 2020", "otherItem": "in future" } }, { "firstVisit": { "prettyDate": "Monday, July 04, 1900", "otherItem": "WAY Way in the past" } } ] }; $(function() { for (x in visitor_data.lastVisits) { var para = document.createElement("p"); var paraText = document.createTextNode(visitor_data.lastVisits[x].firstVisit.prettyDate + " : " + visitor_data.lastVisits[x].firstVisit.otherItem); para.appendChild(paraText); document.body.appendChild(para); } }); </script> </head> <body> </body> </html>
  5. Did you mention that in your error report? Cause the only probable time they would visit this forum, is when they suddenly remember 'OH yeah, we have a forum'
  6. dsonesuk

    Question on rel="nofollow"

    Any link from other site pages , menu, sitemap or external website pages that link to a page, the bots will attempt to visit that page. You may have 'nofollow/noindex' in 'robots' meta tag or have file robot.txt denying all bots to a page through these, but! Unfortunately not all bots follow these set rules.
  7. LastVisits within JSON object is not defined correctly visitor_data = {"lastVisits": [{"firstVisit": {"prettyDate": "Monday, May 14, 2018"}}]}; visitor_data.lastVisits[0].firstVisit.prettyDate;
  8. dsonesuk

    cookie coding

    It seems with the introduction of output_buffer this is no longer true, and probably why w3schools developers with their years of experience, decided to ignore this rule as its no longer relevant for their setcookie() examples.
  9. dsonesuk

    cookie coding

    Then w3schools.com seriously need to correct their tutorial examples and advice on placement of setcookie(), to reflect this then. Even the php.net site gives confusing information "prior to any output, including <html>", which suggests the idea that doctype is fine, since the <!doctype > been around a long time now. It would be better to say " prior to ANY output including html output and any white spacing"
  10. dsonesuk

    cookie coding

    HMMM, strange that, It states here https://www.w3schools.com/php/func_http_setcookie.asp and here http://php.net/manual/en/function.setcookie.php It needs to be before <html>
  11. dsonesuk

    cookie coding

    polly want a cracker
  12. dsonesuk

    cookie coding

    It seems the error relates to sessions not cookies, and since it says line 94, In my mind its not related to the cookie code you have supplied. <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <?php $new_cookie = "123456789abcdefg"; setcookie("username", $new_cookie, strtotime('+30 days'), "/", "", "", TRUE); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" id="viewport" content="target-densitydpi=high-dpi,initial-scale=1.0,user-scalable=no" /> <title>Document Title</title> <script type="text/javascript"> </script> <style type="text/css"> </style> </head> <body> <?php echo $_COOKIE["username"]; echo "<br />"; print_r($_COOKIE); ?> </body> </html> This is what we are discussing.
  13. dsonesuk

    cookie coding

    You can only retrieve set cookie data on the second request for example reloading of same page again, or goes to another page and retrieves it then. http://php.net/manual/en/function.setcookie.php
  14. dsonesuk

    Testing a radio button ON or OFF?

    The part of code using 'print' is PHP.
  15. dsonesuk

    cookie coding

    On loading of the page the first time NOTHING if the cookie does not already exist, but the cookie will be set by the second line. The second time the page is loaded because the cookie now exists, the first line will cause it to be deleted, then the second line will set it again and the circle will start over delete, set on page load, delete, set on page load and so on... It will be deleted. NOTE: With your current code, it won't expire i.e be deleted, as the expiry date increases by 30+ days from current date everytime time it is loaded.
  16. dsonesuk

    cookie coding

    The first won't be set at all! Because it is using a past date, any cookie using expiry date below current Date and time is deleted. So only the second will be set.
  17. Your NOT! using external are you? You are using internal, with PHPmailer sending by SMTP, which comes in all three of those packages which includes 'Lite'. One of the main problem is when you use your actual gmail account username instead of domain named account email, as mentioned for gmail and especially yahoo also is suggested using CC for your actual gmail account.
  18. dsonesuk

    w3schools template does not validate

    Since it is hiding, use the first img src or, small blank img src instead, since this will be overwritten when the modal is initiated. You also need an empty alt attribute for this img, plus <head>...</head> tags also which holds title, external links, JavaScript, css etc.
  19. Check out this site detailed listing of problem solving for contactform7, look at 'SMTP Mail Problems with Gmail and Hotmail' especially at http://kb.cf7skins.com/contact-form-7-email-issues/
  20. It should be under settings -> security heres a link https://support.google.com/accounts/answer/6010255?hl=en
  21. Right! Did you check your web account and check if your emails where blocked and dumped in the spam folder, while you were testing and make sure 'allow less secure apps' is set to 'on', also if not already.
  22. Easy WP SMTP has test option, did it work in that test?
  23. I suppose you did changed the SMTP, port and encryption type to required settings for GSuite email?
  24. dsonesuk

    Reading a $_SERVER Variable with an AJAX Call

    erk! polly want a cracker
  25. dsonesuk

    Reading a $_SERVER Variable with an AJAX Call

    Maybe you should check this, if i remember rightly, your site goes about collecting lots of information from pod-casts and like to display on your site, did seem slow in processing, if you are on shared server, it maybe combination of the others sharing the server and yours that put it over the edge. https://www.hostpapa.co.uk/knowledgebase/causes-excessive-shared-web-hosting-server-usage/ If you check the Network tab of Web Developer tool it should give indication of what is taking excessive amount of usage time to process.
×