Jump to content

All Activity

This stream auto-updates     

  1. Past hour
  2. iwato

    How to Prepend Zeros to a Numerical Value

    Dsonesuk. thank you, but I am only unclear about that part of the implementation that encloses the number 2 in parentheses. Why is the number two enclosed in parentheses? Roddy
  3. Today
  4. Most browsers will show a collapsible representation of a data structure of you log it using console.log().
  5. justsomeguy

    Selecting a Value of JSON Object with Javascript

    The computer doesn't care how many items are there, the only thing that matters is whether it follows the correct format. There are all kinds of text editors that will let you collapse whatever part of the structure you want. The built-in developer tools in the browser will do that also if you print the structure to the console. There sure is, and the browser does all of that automatically. I have never written code to parse a JSON structure, there's no reason to write that when it's a format the browser understands natively. JSON is native Javascript, it stands for Javascript Object Notation. The browser already understands it, you don't have to parse anything like that yourself. Yep. var obj = JSON.parse(json_str); console.log(obj);
  6. 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)
  7. iwato

    How to Prepend Zeros to a Numerical Value

    Great! But ... I still do not understand it. What pray-tell is the meaning of the numbers enclosed in parentheses. Do the parentheses convert the number number into an object? Roddy
  8. GENERAL: One of my colleagues claims that no one likes CSS. But surely, someone does, else it would not exist. Unfortunately, I am not one of those who is very fond of it. Probably because I do not understand it. Dsonesuk once told me that id takes precedence over class. The furtive fox told me to insert my stylesheet dynamically, so that I would be sure that the needed CSS would be present when my dynamically HTML was in need of it. I have accommodated my CSS specification in both of these ways, but still it does not work. Rather, when I visit the Inspector menu of my web-console, it looks like a graffiti-board that someone was too lazy too clean and on which he simply crossed out everything that he did not like. SPECIFIC: I am trying to get my referral URL to break when it gets to the end of the div block in which it is contained. In order to achieve this I entered the following piece of code in my stylesheet. The url does not wrap. Although the inspector of my web console indicates the presence of my specification, it also shows that the rule has been cancelled. Truly I do not get it. #yp_container #current_referral_url { overflow-wrap: normal; } SOURCE: Please open to the mainpage of the Grammar Captive website and click on the phrase Your Data and You under the heading Visitor Profile in the navigation bar. Look for the term Referral URL and note, if you are able, that the URL exceeds the size of the fieldset and div in which the value of the URL is contained . QUESTION: What more must I do to achieve my goal?
  9. 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>
  10. 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>
  11. PROBLEM: The following script is purported to add a select number of zeros to the left of a numerical value. Although it appears logically correct, I do not know how to call the function thus created. The SCRIPT Number.prototype.pad = function(size) { var s = String(this); while (s.length < (size || 2)) {s = "0" + s;} return s; } REQUEST: Could someone please give an example of how I could convert the number 2 to appear as 002 using the above script. Roddy
  12. OK. I have fixed the problem. I am now able to get prettyDate to appear. Clearly I misunderstood the structure of the object read by the $.ajax( ) success function. My having misinterpreted the structure of this object was no casual error, however. For, the object consists of nearly 2000 lines of comma separated property-value pairs, nested array-like structures, and the like. As a result, I am of the firm conviction that similar errors will occur in the future until I learn how to traverse and display the content of the object that I am dealing with. Visual inspection, something that I can now do, is not enough, as I have no means of collapsing the various sub-elements of the object. This said, surely there is a formal methodology for parsing the structure of a complex, many layered JSON object with Javascript. Can this be achieved through a single, highly flexible, recursive function? Or, must it be achieved one layer at a time through painstaking trial and error? Still this latter would be better than what I am doing now. Could someone, please, point me to a tutorial about how to parse and display such an object. Roddy
  13. 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'
  14. Thanks; I just did what you suggested. I would still recommend, though, that they include a "REPORT ERROR" on an Exercise page as well.
  15. There isn't, but you can send a report from the tutorial page that the example belongs to, the link I gave in my previous post. You can describe the issue in the report and they should be able to find it from there.
  16. Thanks but there's no "REPORT ERROR" hyperlink at https://www.w3schools.com/html/tryit.asp?filename=tryhtml_attributes_single_double; that's where I found the "paragraps" typo (it's not at https://www.w3schools.com/html/html_attributes.asp).
  17. I think you're most likely to get the staff's attention by visiting this page and clicking the "REPORT ERROR" link at the bottom of the page.
  18. (The incorrectly spelled) "paragraps" needs to be replaced with (the correctly spelled) " paragraphs" in the following line at https://www.w3schools.com/html/tryit.asp?filename=tryhtml_attributes_single_double: <p>Move your mouse over the paragraps below to see the effect:</p>
  19. Yesterday
  20. Ingolme

    Question on rel="nofollow"

    Google will not find it through that specific link, but it is most likely capable of finding the page through other means. If you have a page that's public on the internet, Google's crawler will usually find a way to it. If you want to prevent Google from indexing the page, as I said before, use robots.txt or the meta robots tag to indicate that you don't want it indexed.
  21. 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.
  22. LastVisits within JSON object is not defined correctly visitor_data = {"lastVisits": [{"firstVisit": {"prettyDate": "Monday, May 14, 2018"}}]}; visitor_data.lastVisits[0].firstVisit.prettyDate;
  23. Meinolf Müller

    Question on rel="nofollow"

    Do you mean "when it finds it" directly from the given link or if the url is referenced thru another path within the site? The reason I put those questions is, that some people don't understand what I mean. They tell me, that you and they do mean the same, but say, that the link defined with rel="nofollow" is only indexed, when reachable thru another path, e.g. thru sitemap. Regards Meinolf
  24. My first guess would be that what you have is just a string instead of a JSON object. Log the full object into the console to see what it contains.
  25. DILEMMA: I have a fairly complex JSON object that is introduced via an AJAX call. Unfortunately, my control panel tells me that it is undefined. Is this because it has no value? Or, is it because I do not know how to read the value properly? {"lastVisits"[{"firstVisit":{"prettyDate":"Monday, May 14, 2018"}}]} The name of the variable into which it is read is visitor_data. Am I reading the value of correctly? visitor_data.lastVisits[0].firstVisit.prettyDate Roddy
  26. Ingolme

    Link to this buttom

    Just replace the <button> element with an <a> element that has the same class attribute. The class is important. <a class="button"><span>Hover </span></a>
  27. Last week
  28. MARCELO

    Link to this buttom

    How can i add a link in this buttom: https://www.w3schools.com/code/tryit.asp?filename=FRM3ZD7H5SZE I thought i should only add to it this: <a href="https xxx">Hover</a> but its not working Thanks.
  29. westman

    user agreement

    Hi all, No PHP or cookies today just text. I would like to update my Terms of Use / User Agreement - legal page. I am terrible with page content like this and would like to use a good free template. Where do I go for this?
  1. Load more activity
×