bbarrick
-
Posts
6 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by bbarrick
-
-
Oh, so the document object is tossed out the same way a variable is in JavaScript once it's done with it?When you change node values, you change the document object, which is not a real document. To change an actual document, you would need to stringify the xml and post it to your server; a script there would save it as a file. That's actually quite easy. But you'd also want to add things like security and validation. -
http://www.w3schools.com/dom/tryit.asp?filename=try_dom_change_nodevalue I guess maybe there is something in the .js file that it references in the head that calls a PHP function on the server side? Sort of misleading I guess.
-
That's what I've heard, but according to the tutorials on this forum you can update xml values with javascript. This isn't going to be an external site that I'm working on, so I don't want to go so far as to setting up a webserver and php. Basically I have a computer that is running a 24 hour display of information(right now it's powerpoint presentation). It's on the network, and I was hoping that I could create a series of automatically redirecting web pages to replaces the powerpoint presentation and an html form that would update an xml file and change what was being displayed on the information screen.Javascript can't change a file, you'll need to send the data to a server-side script like PHP that can modify files. -
Ok, thanks...I thought I had it in there. I commented out loadXMLDoc and added .value but it still didn't update the XML file.Try document.getElementById("inputname") .value Note. There should be no reason to use loadXMLDoc since you already loaded that doc in your XMLHttpRequest object. -
Could use a little help with this if you guys don't mind. This is just for testing purposes for a potential project. Trying to keep it simple at this point. I have an HTML file called projectform.html. Basic html input box with a button. I want to type a name into that box, click on the button and change the value of an XML file. projectform.html
<html><head> <title>Information Screen Form</title> <script src="jquery-1.9.1.min.js"></script> <script src="project.js"></script> <script>if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest();} else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","datatest.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML;</script> </head><body> <div id="main"> <input type="text" id="inputname"> <input type="button" onclick="savename()"; value="Submit"></div></body></html>
project.jsfunction savename()
{ xmlDoc=loadXMLDoc("datatest.xml"); x=xmlDoc.getElementsByTagName("fname")[0].childNodes[0]; x.nodeValue=document.getElementById("inputname");}
XML just has the tags at this point. <?xml version="1.0" encoding="UTF-8" ?>
<nurse><fname>Tonya</fname></nurse>
Changing XML Value
in JavaScript
Posted