Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by Jay@TastefulTitles.com

  1. I have several different pages that all need access to the same XML data file. I'm trying to use this fairly-standard function to load the file when the page loads. If I call getXMLFile() from within each pageLoadFunction, it works, but I'd like to use it to set up some other vars and avoid duplicating code. getXMLFile = function(callback) { var request = new XMLHttpRequest(); request.open("GET", "MyFileName.xml"); request.setRequestHeader("Content-Type", "text/xml"); request.onreadystatechange = function() { if (request.readyState == 4 && request.status == 200) { callback(r
  2. Solved! 😀 My brain had a sudden flash, so I decided to try something. Lo and behold, it worked! Here's what it took: $xml->getElementsByTagName("customers")->item(0)->replaceChild($node, $oldnode); I had not understood from the examples that I have to start with the parent node to replace a child node. Seems logical now that I've found it, but I sure didn't see it before. I doubt I could have got there if you hadn't found my var error, so many thanks for that.
  3. So I do. Thanks for catching that! I was so hopeful that correcting the var name would solve the problem, but there is no change. That line now looks like this: $node->replaceChild($node, $oldnode); //THIS LINE FAILS I think that may have been a relatively recent error, as I changed some var names to make it easier to compare with the example code, but its failure predates that. I hope you can take another look and find what else is screwed up. Logically, there must be some problem with the params I'm sending in this line, because the previous line executes without pro
  4. At Ingolme's suggestion, I've switched from simpleXML to DOMXML for this because I need to be able to replace a node. I've done my best to follow PHP.com examples, and everything seems to work up until the point of the actual replacement. I hope you can spot what's keeping it from working. The vars found in the heredoc are assigned earlier from the customer input form. if $found is positive, it contains a cId (customer ID) that exists in the DB and should be updated with any new info (code shown). If negative, it's abs() is the cId for a new node to be added (code omitted here). In $xm
  5. I like to use this hack when adding values in JS: sum = -(-x - y); It eliminates the ambiguous '+' operator altogether, along with any type confusion. It can also be put into a function: function add(a, b) {return -(-a - b)} sum = add(x, y); This may be slightly less efficient than declaring the var as numeric, but I think it makes for neater code, and there are times we want to make use of JS's loose typing, so the var can be used as text in one place and numeric in another.
  6. I will look at it. Do you have an example of using DOMDocument? That might work just as well for me. Thanks!
  7. Okay, I'll hunt for a DW replacement. It has to run on OS10.11.6. Any recommendations? Meanwhile, I can upload and run the code regardless of the error message, but it doesn't seem to work. I was wondering if you could see a reason why. Is this a reasonable way to approach my goal? Some of the discussions I've read seem to imply I have to insert each tag separately, but I can't tell for sure.
  8. "Syntax error on line 1" is apparently how DW CS5 reports a syntax error anywhere in a PHP doc. The only thing on line 1 is "<?php". The error could be in line 12,345, and fixing it will make the error report go away. In this case, if I comment out the heredoc (lines 138-155), it reports "No syntax errors."
  9. I'm a novice to PHP. What I want to do is add a new customer record to my XML database. It looks as if a simple way to do this would be to create a string using heredoc, which will insert the variable values, then turn it into a simpleXML object: $xml=simplexml_load_file("Test data.xml"); //load XML file // these $vars are all defined from form input in previous code $str= <<<EOS <!----> <customer> <cId>$Customer</cId> <organization>$organization</organization> <website>$URL</website> <contact>$name</contact>
  10. Most of my product pages include a link to a window showing the text of my translation, formatted with CSS to appear as a series of scrolling "slides." Each "slide" is a separate <div> containing 2, 1, or 0 <p>'s. The number of slides can range from ~25 to ~1,000. On some of the larger ones, I'm wondering whether there is an advantage to splitting the text HTML between two separate shell divs? If I put the first 50 or so slides in one <div>, will it load and display faster than if I put all 800 slides in the same <div>? I'll try to illustrate: <body>
  11. A button in my window opens a new, narrow window centered on the screen. window.open("/myWindow.html", "_blank", width="400", height=screen.height, top=0, left=(screen.width / 2 - 200)); My naive assumption was that, on a large screen (laptop or larger), this would create a window 400px wide. On my 13" macbook, according to the information in the Safari web inspector, it creates a window only 347.826px wide. The CSS of the new window sets a background, then creates a <div class="shell">, 300px wide. The setting of margin:0 auto is meant to center the "shell" in the new wind
  12. Good grief! I can't believe I looked at that for so many hours without seeing it. It sure helps to have another set of eyes. Many thanks!
  13. I'm trying to fill a table on my HTML page with values from my xml data file. Var v is an HTMLCollection object containing these nodes extracted from the xml file: <pubisher>Peters</pubisher> <translator>Jay Reeve</translator> <slidecount>885</slidecount> <pagecount>189</pagecount> <other></other> I'm using this chunk of code. The vars are all local and declared earlier. for (r=0;r<v.length;r++) { str=v[r].innerHTML; //str gets the value "Peters" if (str>"") { fld=v[r].nodeName; //fld gets the value "pu
  14. It turns out I had merely neglected to include this line in my code: <meta name="viewport" content="width=device-width, initial-scale=1" /> Doing that took care of the problem. You'd think I would know better by now, but having never run into that before, it took me quite a while to find it.
  15. I thought I had fixed the missing px, but hadn't. Thanks for pointing it out. I have not heard of the security problem before, nor the simple fix. Thanks! Would you be interested in explaining how that helps? What could some miscreant do with my folders list, and how does the empty index.html prevent that?
  16. Apparently removing the <style></style> tags from the css file allowed it to work. I don't know why the first declaration (body) was the only one hindered, but now it seems to work fine. A newbie mistake, I'm sure, but you might keep it in mind for the next one who asks. Thanks for your input.
  17. 1. Okay. I didn't know that. I don't think I had any. 2. The body css has all the same parent tags as the others, but it's the only one that doesn't work. Is that true even in a css file? I'm missing the point of your first response. There is no body styling from the separate css file. There is from the html file.
  18. My site opens a html window containing a long series of divs with text. It uses a separate css file, all of which works except for the body styling. If I put the same styling (via cut & paste) into the html for the window, it works fine. The html and the css files are in the same folder. There's no reason I can't add those few lines of css to the html in the ~30 windows that use it, but I'm curious why it won't work the other way. Here's the code: <style> body { background-color:#600; background-image:url(../images/Curtain%20narrow.jpg); } </style> You can view t
  19. My site opens a window using this code: function view() { var title=workId("title"); var L = (screen.width - 355) / 2; var H = screen.height; var p = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=339,height='+H+',top=0,left='+L+'"'; window.open("/slides/"+title+".html", "_blank", p); } I've hard coded the width of the window because it is essentially a popup and needs to be that width to have the right proportions. The longest lines of text should fill the box without breaking. When I view it in Safari's "Responsive Des
  20. It took many hours, but I have it working now. Thanks for the tip!
  21. I have been using the following function to load my xml data file. It used to be solid, but now it often (but not always) fails to load and goes on to create errors in the next function when it tries to use the data. I don't know whether that's because the data file is growing larger, or if that's unrelated, but I need something I can depend on. I've experimented with some other load functions found online, but have had no more success with them. I'm using the synchronous version, as I understand it is supposed to wait until the load is done before going on. Is my understanding flawed? I
  22. Overflow:hidden seems to do the trick. I thought I had tried all the options, but I might have assumed incorrectly that hidden would hide part of the img. Thanks a million!
  23. Removing the float sends all the text below the img, which keeps the div from being too short, but is clearly not what I want. No, there is no positioning in this div. Do you have something to suggest?
  24. I have a div that contains an img and text. The img is floated left at 40% width. The height of the img and the amount of text may vary. What I want to do is make sure the parent div is at least high enough to enclose the img. (It may be higher if the text is longer than the img, but that case works fine already.) I've tried various overflow settings, but none seem to accomplish this. Is there a way using css or straight js?
  25. Thanks for the quick response. I've been passing arguments to functions for more than 40 years. (A game I wrote for the Commodore 64 was chosen as one of the 12 best ever published in Compute's Gazette.) But I've only worked in js occasionally for 10 years, and am new to callbacks. Even so, I can't see how what you did is different from what I did. I declared 3 functions. None of them required any arguments to accomplish their function. (Neither do the 3 in my real code.) I passed function test2 as a callback to test1.... Okay, I think the lightbulb just went on... I was passing
  • Create New...