JavaScript - Parsing Data From An Xml File
Hello,
I'm trying to parse my data from an xml file now and print it out on the page based on date from my existing code. I have that working, with each item formatted the same way on the page What I'd like to do now is alter it a bit to make the most recent (the item listed on the top of the page) formatted differently and the rest of them as it is now. Something like - (if 1st <li> then build html like this else build html like that) I hope this makes sense. Code: <?xml version="1.0" encoding="utf-8" ?> <books> <book title="CSS Mastery" imageurl="http://cdn.net.tutsplus.com/045_LoadXMLWithJquery/images/css.jpg"> <description> 08/01/2010 - Content </description> </book> <book title="Professional ASP.NET" imageurl="http://cdn.net.tutsplus.com/045_LoadXMLWithJquery/images/asp.jpg"> <description> 08/02/2010 - Content </description> </book> <book title="Learning jQuery" imageurl="http://cdn.net.tutsplus.com/045_LoadXMLWithJquery/images/lj.jpg"> <description> 08/03/2010 - Content </description> </book> <book title="Learning jQuery" imageurl="http://cdn.net.tutsplus.com/045_LoadXMLWithJquery/images/lj.jpg"> <description> 08/04/2010 - Content </description> </book> <book title="Learning jQuery" imageurl="http://cdn.net.tutsplus.com/045_LoadXMLWithJquery/images/lj.jpg"> <description> 08/05/2010 - Content </description> </book> </books> Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Load XML With jQuery</title> <script src="jquery-1.2.6.js" type="text/javascript"></script> <link href="StyleSheet.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> $(document).ready(function() { /*Gets current date*/ var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); var date = new Date(); /*var curr_date = d.getDate();*/ var curr_date = 3; var curr_month = date.getMonth(); var curr_year = date.getFullYear(); $.get('myData.xml', function(d){ /* $('body').append('<h1> Title</h1>');*/ $('#col-a').append('<ul id="tips"/>'); $(d).find('book').each(function(){ var $book = $(this); var title = $book.attr("title"); var description = $book.find('description').text(); var imageurl = $book.attr('imageurl'); var html = '<li class="tipItem" style="list-style:none;display: none; li">'; html += '<img class="bookImage" alt="" src="' + imageurl + '" /> '; html += '<p class="title">' + title + '</p>'; html += '<p> ' + description + '</p>' ; html += '</li>'; $('ul').append($(html)); }); var tips = $('#tips .tipItem'); tips.each(function(i) { if (curr_month == 8 && curr_date <= i){ $(this).hide(); } else { $(this).show(); } }); tips = $.makeArray(tips); tips.reverse(); $(tips).appendTo(document.getElementById('tips') ); }); }); </script> </head> <body> <div id="col-a"></div> </body> </html> Similar TutorialsHi, I'm trying to write a little Javascript that would parse a CSV file that contains a name and date, and only display the name if the date matches today. Here's some example data: Name, Date Joe, 6/10/2010 Jane, 7/11/2010 If today were 6/10/2010, the output of the script would just be "Joe" Can anybody help? Thanks! Anyone that can help on this one it would be greatly appreciated... I need to make a form parses a result from column 1 of txt/csv file that has 7 columns. Column 1 is pay, column 2-7 are how many and the associated rows are the answers. In short 1 2 3 4 5 6 700 50 55 62 75 80 99 so if the customer enters i make 700 and i need 2 the result would be 55 as the output. Any idea on how to make that work with javascript? if (pay <=700 && widgets = 2) { document.write(55) elseif (pay <=700 && widgets = 1) document.write(50) is this doable and is it the easiest way to accomplish this? hi, I am a newbie. Using Java script, I need to open and read CSV file. I need to read the third column values and store in an array. Please help me regarding this. Thanks, Hanumanth. Hello everybody, I am currently working on displaying KML-values of ElementTags within my KML File. I already integrated the KML file as an overlay to my Google Map. But how am I able to parse the GGeoXml-object or how am I able to parse external ("http://www.myexample.org/polygons.kml" instead of just "polygons.kml") XML-files? At the moment my code for loading the geoxml file looks like this: Code: function initialize(kmlFile) { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map_canvas")); map.setUIToDefault(); map.setCenter(new GLatLng(53.763325,-2.579041), 9); // ==== Create a KML Overlay ==== if(!(kmlFile==null)){ //check if it doesnt start with "http://" if(!(kmlFile.startsWith("http://"))){ kmlFile = "http://" + kmlFile; $('kmllink').value = kmlFile; } var kml = new GGeoXml(kmlFile); //add Overlay to the googlemaps window map.addOverlay(kml); //$('subject').value = "SUBJECT"; //$('content').value = "CONTENT"; kml.gotoDefaultViewport(map); // Store center and zoom as properties of the object kml var centerKML= kml.getDefaultCenter(); var zoomKML = map.getZoom(); map.panTo(centerKML); map.setZoom(zoomKML); } } } And for parsing local XML-files this code works already: Code: function loadXML() { if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest(); } else // Internet Explorer 5/6 { xhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xhttp.open("GET","test.kml",false); xhttp.send(""); //xmlDoc=xhttp.responseXML; xmlDoc = xhttp.responseXML; var placemark=xmlDoc.getElementsByTagName("Placemark"); alert(placemark[0].getElementsByTagName("name")[0].childNodes[0].nodeValue); ajaxLoader("http://www.zki.dlr.de/mod/ext/fireModis/yesterday_en.kml","Placemark"); } My question: Is there any way to integrate parsing external xml files in any of these two functions? Best regards, TsEMaNN Hi all, I have a simple XML file that looks something close to this: Code: <presence id="12345"> <status>in a meeting</status> <priority>1</priority> </presence> <x> <picture>blahblah</picture> </x> <x> <hash>string</hash> </x> I need javascript to pull the status from this file. Here's what I have for that: Code: <span id="login_status"></span> <span id="secondlogin_status"></span> <script type="text/javascript"> 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","https://www/user1.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; document.getElementById("login_status").innerHTML= xmlDoc.getElementsByTagName("status")[0].childNodes[0].nodeValue; document.getElementById("priority").innerHTML= xmlDoc.getElementsByTagName("priority")[0].childNodes[0].nodeValue; xmlhttp.open("GET","https://www/user2.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; document.getElementById("secondlogin_status").innerHTML= xmlDoc.getElementsByTagName("status")[0].childNodes[0].nodeValue; document.getElementById("second_priority").innerHTML= xmlDoc.getElementsByTagName("priority")[0].childNodes[0].nodeValue; </script> Here's my problem: If my xml file only has the one "parent" (meaning: Code: <presence id="12345"> <status>in a meeting</status> <priority>1</priority> </presence> ) this works WONDERFULLY. However, when the second and third "parents" are added (<x>), the script returns blank output in the spans. I feel almost certain my issue is related to this: http://codingforums.com/showthread.php?t=140810 but I've tried to switch that around but it doesn't seem to provide any different results. If you require a bit more info on the project itself, here's a rundown: This xml file is created by an internal chat app at my office. Each employee has their own xml file listing their current availability and status (hence "in a meeting"). This will be used to determine the availability of certain individuals in the building without having to be logged in to the chat app. That's why there's multiple xml files going to be used (roughly 10-15 in the end). i am using the jquery plugin uploadify as an image uploader, i want the image to be able to be uploaded and then redirected to another page where you will see a thumbnail of the picture and be able edit the caption, description, etc... ... i am not interested on how to do it but only how to control variables from the files uploaded.... i have uploadify on a upload.php and it accesses the script uploadify.php to process the file handling in a regular php uploader, i could put the uploaded file information into variables and redirect to another page and use those variables... with uploadify i am not sure how to accomplish this... i can't use uploadify.php to create variables to be used, after the upload, the user remains on the page uploadify is installed on(upload.php)... how can i take the file information and put it into variables and be redirected with the ability to call those variables i'm sorry i am new to javascript and i'm trying to understand it the best i can, if someone could help me achieve this i am thinking of using a xml file as a data base for example , the xml file stores a list of reference numbers which is allocated to a url or a name such as 0123456789 and i have a text box on a webpage and the user types in a reference number and the javascripts reads the xml file to check if its a valid reference number i.e a registered number i am new to working with xml etc... so would be nice to have a little help here EXAMPLE <DATA> <REF> <0123456789>JOE</01234567890> <1111111111>www.google.com</1111111111> </REF> </DATA> id like it to read the specific data thats contained within the tag such as 0123456789's tag = JOE Hi all, How can i read CSV data from the text file using Java Script.Please give me the script for the problem. Thanx, Nari well i'm kind of new to this website and scripting with javascript but i am wondering: in a client side .js file i have some coding which results in a string which is stored in a variable called exportData now i want that string to be written into a text file on a server but how do i do that? it is not local on the client's pc and i can't find how to do it anywhere... can you guys help me? greetings, Fady Hello All, I always wonder that how to display any sort of data or HTML codes by just simply calling or including a Javascript file in other HTML file or a webpage. If you didn't understand what I want to say, I would like to give an example like AdSense gives a javascript code that need to be put where we want to show ads. And the ads appear, similarly how to display any HTML code with just inclusion of Javascript file. An other example is - <script type="text/javascript" src="http://example.com/scripts/javascript/source/somescript.js"> <div id="div_one"></div> <div id="div_two"></div> <div id="div_three"></div> </script> Now this script will show some HTML inside first div, some on second and so on. So How can I do that, please explain with an example... Thanks. I am trying for a javascript code that would ask for the excel file location when run, fetch data from two columns till eof in an excel file (MS Excel 2010), append it to an existing text file and upload the plain text file to an ftp location. The ftp username, password and location needs to be hard coded in the script. Is this possible? I'm trying to work with XML DOM for the first time as I need to grab a value from a SOAP request. I've been following this: http://www.w3schools.com/xml/xml_parser.asp, which says modern browsers won't parse xml files from another server for security reasons. How would I got about doing this then? I've been using the price of crude oil as an example (http://www.google.com/ig/api?stock=OIL) and want code portable enough to put on something like Tumblr, so I don't think I can actually save the file locally first. Any ideas? Thanks, Zach I'm trying to parse out location data from XML that is passed back from Google. It currently parses the data correctly, the problem is that it grabs all of the matching tags, instead of just the first results set. Here's an example of the output. Here's the code I'm using to achieve this: Code: function(){ var url = 'http://maps.googleapis.com/maps/api/geocode/xml?address=NewBrunswick,NJ&sensor=false'; $.ajax({url: 'proxy2.php?url='+url, type: "GET", dataType: "text", success: function ($data) {$data = $($data); lat = ($data.find('geometry').find('location').find('lat').text()); long = ($data.find('geometry').find('location').find('lng').text()); }});}); How would I change it so that it only grabs the data from the first set of results? Hey, Im fairly new to javascript but I am an experianced php programmer. I have been parsing XML information using php, but my CPU usage has been too high recently due to this. I am trying to convert my scripts to javascript, but I am unsure how I can do this using javascript. I think that if I get started off, the rest will be easy. One of my XML files is located at Code: http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=bbcradio1&api_key=c910b0bc1e2d4e64964ebcd2d69c255c&limit=500 Basically I have been trying to grab the Name, Artist and large image of the most recent <track>. Any help would be greatly appreciated and linked too on my website . Tim Hi All I have a xml string located in a hidden textbox that i need to parse how do i get it into a xml object I thought nievly i could xmlDoc = document.getElementById("XML").value alert(xmlDoc.getElementsByTagName("SupplMets")[0]); document.write("<table border='1'>"); but obviously i need to do some more work to get it into an xml object ...any ideas the end goal here is to get the data in the xml into a table here is what the xml string looks like <SupplMets TumorSupplementalId="272341"><SupplMet TumorSupplMetsId="109130" SiteOfMetastasis="C020" DateOfMetastasis="20010101" MetastasisIdType="" MetastasisEliminated="" MetastasisSD="02-003710" /></SupplMets> Hello, I am trying to assign a variable using a form value, but it returns as undefined. However, if I directly set em (uncomment them), it works. Why are my values not working? Code: <script type="text/javascript"> //lichbloom = 2; //frostlotus = 5; lichbloom = document.endlessragevalue.lichbloom.value; frostlotus = document.endlessragevalue.frostlotus.value; var endlessrage = lichbloom+frostlotus; </script> <form name="endlessragevalue" id="endlessragevalue"> Lichbloom <input type="text" size="20" name="lichbloom" value="2" /><br /> Frost Lotus <input type="text" size="20" name="frostlotus" value="5" /><br /> <script type="text/javascript">document.write(endlessrage);</script> </form> thanks for looking! This is an example of an email: REGION: CICSPSC1 PROGRAM: SCC23COB ABEND CODE: ASRA TRANSACTION: CORM DATE: 02/25/2010 TIME: 08:20:06 This javascript code is capable of parsing this email and return the information in the TRANSACTION: Code: var strReplace = email.body_text; strReplace = strReplace.replace(/\n/g,""); strReplace = strReplace.replace(/^REGION:\s+\w+\d+PROGRAM:\s+\w+\d+\w+/i,""); strReplace = strReplace.replace(/^\s+CODE:\s+\w+TRANSACTION:\s+/i,""); strReplace = strReplace.replace(/DATE.*$/i,""); gs.log(strReplace); So at the moment I am trying to parse this email information (below) and return the HOST: field data. Any help on this would be greatly appreciated!! Notification Type: PROBLEM Host: ka-whsym-r8 State: DOWN Address: 10.2.1.194 Info: PING CRITICAL - Packet loss = 100% Date/Time: Mon May 24 14:30:16 CDT 2010 I'm developing a DHTML based Flashcard app that will work using firefox (MiniMo on Mobile Devices). It's working fine (reads and writes datafile to and from the local disk). However, when i start reviewing the flashcards, it seems to have some parsing issues. Do explain more about the data file, it is a 3 record CSV file with 3 catagories: ChineseCharacter, PinYin, English For some reason or another, i can figure out how to correctly pars out and put the correct data in the corresponding Data Arrays. I would like to get this program working as soon as i can, i plan to use it to study for the HSK test (Chinese proficiency test). I'm supposed to take it in about 4 months. - yes im cramming here's my code: Code: <html> <head> <script language="javascript"> // Set Global Variables var ChineseCard = new Array(); var PinYinCard = new Array(); var EnglishCard = new Array(); var Records = new Array(); var Know = 0; var DontKnow = 0; var CurrentCard = 0; var NumberOfCards = 0; var DataFile = "C:" + String.fromCharCode(92) + "FlashCard.txt"; var Delimeter = ","; function init() { document.getElementById("FlashCardPlayer").style.visibility = "hidden"; document.getElementById("FlashCardEditor").style.visibility = "hidden"; document.getElementById("MainMenu").style.visibility = "visible"; } function ShowPlayer() { document.getElementById("FlashCardPlayer").style.visibility = "visible"; document.getElementById("MainMenu").style.visibility = "hidden"; document.getElementById("FlashCardEditor").style.visibility = "hidden"; LoadFlashCard(); } function ShowEditor() { document.getElementById("FlashCardEditor").style.visibility = "visible"; document.getElementById("FlashCardPlayer").style.visibility = "hidden"; document.getElementById("MainMenu").style.visibility = "hidden"; } function ShowMain() { document.getElementById("MainMenu").style.visibility = "visible"; document.getElementById("FlashCardPlayer").style.visibility = "hidden"; document.getElementById("FlashCardEditor").style.visibility = "hidden"; } function ClickShowPinYin() { document.getElementById("PinYin").value = PinYinCard[CurrentCard]; } function ClickShowEnglish() { document.getElementById("English").value = EnglishCard[CurrentCard]; } function ClickKnow() { Know = Know + 1; if(CurrentCard == NumberOfCards) { // Display the score alert("You scored " + Know + " out of " + NumberOfCards); CurrentCard = 0; Know = 0; DontKnow = 0; // clear all textboxes and put index(0) chinese character into the chinese character textbox } CurrentCard = CurrentCard + 1; document.getElementById("PinYin").value = ""; document.getElementById("English").value = ""; document.getElementById("ChineseCharacter").value = ChineseCard[CurrentCard]; } function ClickDontKnow() { DontKnow = DontKnow + 1 if(CurrentCard == NumberOfCards) { // Display the score alert("You scored " + Know + " out of " + NumberOfCards); CurrentCard = 0; Know = 0; DontKnow = 0; // clear all textboxes and put index(0) chinese character into the chinese character textbox } CurrentCard = CurrentCard + 1; document.getElementById("PinYin").value = ""; document.getElementById("English").value = ""; document.getElementById("ChineseCharacter").value = ChineseCard[CurrentCard]; } function ClearEditor() { // Clear all the text boxes in the editor document.getElementById("EditChinese").value = ""; document.getElementById("EditPinYin").value = ""; document.getElementById("EditEnglish").value = ""; } function WriteData() { // Conicate the Record data var WriteData = document.getElementById("EditChinese").value + Delimeter + document.getElementById("EditPinYin").value + Delimeter + document.getElementById("EditEnglish").value + "\r"; // Load the data file's current contents var OldData = LoadFromDisk(DataFile); if (OldData == null) { var WriteDataUTF8 = utf8Encode(WriteData); // The file was blank, so don't try to append null content data SaveToDisk(DataFile, WriteDataUTF8 + "\n"); } else { var OldDataUTF8 = utf8Decode(OldData); var AppendData = OldDataUTF8 + WriteData + "\n"; var UTF8data = utf8Encode(AppendData) // Write the data to the file SaveToDisk(DataFile, UTF8data); } // Clear the TextBoxes to prepare for the next entry ClearEditor(); } function LoadFlashCard() { // Load the FlashCard Information from the DataFile into the Arrays var LoadData = LoadFromDisk(DataFile); // Convert the Datafile from UTF8 to ASCII var LoadDataUTF8 = utf8Decode(LoadData); Records = LoadDataUTF8.split(Delimeter); // Load the Elements in to the ChineseText, PinYin, and English Arrays NumberOfCards = (Records.length -1) / 2; NumberOfRecords = NumberOfCards * 3; // Load the Chinese Characters var Ptr = 0; for (var x = 0; x < NumberOfRecords; x = x + 3) { ChineseCard[Ptr] = Records[x]; Ptr++; } Ptr = 0; // Load the PinYin for (var x = 1; x < NumberOfRecords; x = x + 3) { PinYinCard[Ptr] = Records[x]; Ptr++; } Ptr = 0; // Load the English for (var x = 2; x < NumberOfRecords; x = x + 3) { EnglishCard[Ptr] = Records[x]; Ptr++; } alert(ChineseCard[1]); alert(PinYinCard[1]); alert(EnglishCard[1]); } function SaveToDisk(FileName, Content) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } catch (e) { alert("Permission to save file was denied."); } var file = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); file.initWithPath( FileName ); if ( file.exists() == false ) { file.create( Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420 ); } var outputStream = Components.classes["@mozilla.org/network/file-output-stream;1"] .createInstance( Components.interfaces.nsIFileOutputStream ); outputStream.init( file, 0x04 | 0x08 | 0x20, 420, 0 ); var output = Content; var result = outputStream.write( output, output.length ); outputStream.close(); } function LoadFromDisk(filePath) { if(window.Components) try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); file.initWithPath(filePath); if (!file.exists()) return(null); var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream); inputStream.init(file, 0x01, 00004, null); var sInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream); sInputStream.init(inputStream); return(sInputStream.read(sInputStream.available())); } catch(e) { //alert("Exception while attempting to load\n\n" + e); return(false); } return(null); } // ***************** The following are the functions for UTF8 *************************** // if these are removed or modified in any way, the foreign language characters might not display correctly or at all // Use utf8Encode(str) to Encode data to UTF8 format // Use utf8Decode(utf8Str) to Decode data to ASCII format //an alias of String.fromCharCode function chr(code) { return String.fromCharCode(code); } //returns utf8 encoded charachter of a unicode value. //code must be a number indicating the Unicode value. //returned value is a string between 1 and 4 charachters. function code2utf(code) { if (code < 128) return chr(code); if (code < 2048) return chr(192+(code>>6)) + chr(128+(code&63)); if (code < 65536) return chr(224+(code>>12)) + chr(128+((code>>6)&63)) + chr(128+(code&63)); if (code < 2097152) return chr(240+(code>>18)) + chr(128+((code>>12)&63)) + chr(128+((code>>6)&63)) + chr(128+(code&63)); } //it is a private function for internal use in utf8Encode function function _utf8Encode(str) { var utf8str = new Array(); for (var i=0; i<str.length; i++) { utf8str[i] = code2utf(str.charCodeAt(i)); } return utf8str.join(''); } //Encodes a unicode string to UTF8 format. function utf8Encode(str) { var utf8str = new Array(); var pos,j = 0; var tmpStr = ''; while ((pos = str.search(/[^\x00-\x7F]/)) != -1) { tmpStr = str.match(/([^\x00-\x7F]+[\x00-\x7F]{0,10})+/)[0]; utf8str[j++] = str.substr(0, pos); utf8str[j++] = _utf8Encode(tmpStr); str = str.substr(pos + tmpStr.length); } utf8str[j++] = str; return utf8str.join(''); } //it is a private function for internal use in utf8Decode function function _utf8Decode(utf8str) { var str = new Array(); var code,code2,code3,code4,j = 0; for (var i=0; i<utf8str.length; ) { code = utf8str.charCodeAt(i++); if (code > 127) code2 = utf8str.charCodeAt(i++); if (code > 223) code3 = utf8str.charCodeAt(i++); if (code > 239) code4 = utf8str.charCodeAt(i++); if (code < 128) str[j++]= chr(code); else if (code < 224) str[j++] = chr(((code-192)<<6) + (code2-128)); else if (code < 240) str[j++] = chr(((code-224)<<12) + ((code2-128)<<6) + (code3-128)); else str[j++] = chr(((code-240)<<18) + ((code2-128)<<12) + ((code3-128)<<6) + (code4-128)); } return str.join(''); } //Decodes a UTF8 formated string function utf8Decode(utf8str) { var str = new Array(); var pos = 0; var tmpStr = ''; var j=0; while ((pos = utf8str.search(/[^\x00-\x7F]/)) != -1) { tmpStr = utf8str.match(/([^\x00-\x7F]+[\x00-\x7F]{0,10})+/)[0]; str[j++]= utf8str.substr(0, pos) + _utf8Decode(tmpStr); utf8str = utf8str.substr(pos + tmpStr.length); } str[j++] = utf8str; return str.join(''); } </script> </head> <body onload="init()"> <!-- ***************************************** Flash Card Player ***************************************** --> <div id="FlashCardPlayer" style="position: absolute; left: 0px; top: 0px;" > <input id="ChineseCharacter" type="textbox" style="position: absolute; left: 75px; top: 5px; width: 100px; height: 100px; font-size: 35px;"> <input id="PinYin" type="textbox" style="position: absolute; left: 5px; top: 110px; width: 225px;" > <input id="English" type="textbox" style="position: absolute; left: 5px; top: 135px; width: 225px;"> <input type="button" value="Know" style="position: absolute; left: 5px; top: 170px; width: 100px; height: 30px;" onclick="ClickKnow();"> <input type="button" value="Dont Know" style="position: absolute; left: 125px; top: 170px; width: 100px; height: 30px;" onclick="ClickDontKnow();"> <input type="button" value="PinYin" style="position: absolute; left: 5px; top: 210px; width: 100px; height: 30px;" onclick="ClickShowPinYin();"> <input type="button" value="English" style="position: absolute; left: 125px; top: 210px; width: 100px; height: 30px;" onclick="ClickShowEnglish();"> <a href="" style="position: absolute; left:10px; top: 245px;" onclick="ShowMain();">Home</a> </div> <!-- ****************************************** Flashcard Editor ****************************************** --> <div id="FlashCardEditor" style="position: absolute; left: 0px; top: 0px;"> <input id="EditChinese" style="position: absolute; left: 75px; top: 5px; width: 100px; height: 100px; font-size: 35px;" type="textbox"> <input id="EditPinYin" style="position:absolute; left: 5px; top: 110px; width: 225px;" type="textbox"> <input id="EditEnglish" style="position:absolute; left: 5px; top: 135px; width: 225px;" type="textbox"> <input id="EditClearTextButton" value="Clear" style="position:absolute; left: 5px; top: 180px; width: 100px; height: 30px;" onclick="ClearEditor();" type="button"> <input name="EditOKButton" value="OK" style="position: absolute; left: 125px; top: 180px; width: 100px; height: 30px;" onclick="WriteData();" type="button"> <a href="" style="position: absolute; left:10px; top: 225px;" onclick="javascript:Alert("*sigh* i'm getting to it!");">New</a> <a href="" style="position: absolute; left:10px; top: 245px;" onclick="ShowMain();">Home</a> <br> </div> <!-- ****************************************** Define the Layer for the Main menu ****************************************** --> <div id="MainMenu" style="position: absolute; left: 0px; top: 0px;"> These are the instructions for the Flashcard App. In the future, there should be a score board and a selection of word lists and other such things. However, it's blank for now until i finish this app :) <input value="Study Flashcards" style="position: absolute; left: 50px; top: 170px; width: 120px; height: 30px;" onclick="javascript:ShowPlayer();" type="button"> <input value="Edit Flashcards" style="position: absolute; left: 50px; top: 210px; width: 120px; height: 30px;" onclick="ShowEditor();" type="button"> </div> </body> </html> I have been able to parse a JSON feed before but forwhatever reason this time around I am having a hell of a time getting it working. Here is where I am at right now. So far the script dosn't output anything. Code: <table width="100%" border="0" cellspacing="0" cellpadding="10"> <script> xhttp=new XMLHttpRequest(); xhttp.open("GET","http://biz104.inmotionhosting.com/~cox7co5/api/get_category_posts/?id=5",false); xhttp.send(""); json_data=xhttp.responseText; var parsed_data = eval('('+json_data+')'); var slug="stuff" for (i=0;i<parsed_data.count;i++) { document.write("<tr><td><a href=\"#\" class=\"showlist\">"+parsed_data.posts[i].title+"</a></td><tr>"); } </script> </table> |