Jump to content

Jay@TastefulTitles.com

Members
  • Content Count

    35
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Jay@TastefulTitles.com

  • Rank
    Newbie

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  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?
×
×
  • Create New...