Jump to content

Greywacke

Members
  • Posts

    510
  • Joined

  • Last visited

Everything posted by Greywacke

  1. To get that, try response.getElementsByTagName("Cats")[0].childNodes[0].firstChild.data or response.getElemtsByTagName("options")[0].firstChild.data to get "Fiction".
  2. I might be able to give you some clarity on your question, it sometimes helps to know WHY. If not, ignore this reply... :)Starting a URL with /This targets the root of the current domain, and is called a virtual URL.Starting a URL with ../This directs the script one level up from the .js calling pages location in relative URL's. It's two dots by the way, though from the root of a site - I doubt you would get anything other than a 404 not found... :)Starting a URL with a directory or file name, from where the JS calling page is located for instance images/arb.jpg or index.html.Also a relative URL, and allows you to traverse a directory structure even when called from a few folders into the "tree" :)Starting a URL with http://A complete URL is most often used to link to another site.All URL's in JS files start from the calling pages location (the page containing the <script> tag)'s location so if the JS is called by index.php in the root of the site you can specify relative urls only for JS files used by the directory index.html is in. In javascript documents it's best to use virtual URL's if you want to maintain linking integrity over the site.If it's in a subdirectory such as /help/topic/index.html for instance, and you want to preload /images/arb.jpg for use in the CSS: you would have to specify it as ../../images/arb.jpg - but if its in the site root or one directory up like /help then only one ../ is needed in the URL. At the moment its expecting a directory called . containing helpbox.html in the calling pages location. I would not recommend duplicating files all over your directory structure.And yes, the <!-- --> html comment tags were only used around script blocks to hide the scripts in browsers that didn't support javascript. NEVER use that in a .js file, especially multiple HTML comments around every function (it's generally preferred to keep the components of a site seperate, not mixed).
  3. or if you really have to invoke the link top.frameName.document.getElementById("abcdef").onClick(event); or something similar...been years since i did it though... might have to google a bit to check on cross-browser compatibility.
  4. unless his problem is the similar to mine...(XML Parsing: What am I doing wrong?)one would have to see the xml to know how to reference it.
  5. hi there,here is the xml file. i successfully retrieve it, no problems, it contains N number of services, each with 3 values in text nodes and and multiple attribute, supplier and region tags, each with subtags enclosing text, regions with 4 and suppliers and attributes with 2.i don't think i should think of changing the xml file, i need to parse it as it is / will be. here is the xml with testing data, one supplier, with one region (and its children), and one attribute. the sql secondary tier i can also retrieve no problems for debugging. <?xml version="1.0" encoding="ISO-8859-1"?><root> <service> <serviceid>1</serviceid> <servicedescription>Test Service</servicedescription> <costperlead>20</costperlead> <attribute> <attributeid>1</attributeid> <attributedesc>Test Attribute</attributedesc> </attribute> <supplier> <supplierid>1</supplierid> <suppliername>Test Supplier</suppliername> </supplier> <region> <regionid>1</regionid> <regionparent>0</regionparent> <regionname>Test Region</regionname> <indent>0</indent> </region> <region> <regionid>2</regionid> <regionparent>1</regionparent> <regionname>Test Region 1</regionname> <indent>1</indent> </region> </service> <sql> SELECT * FROM 2_servicescatalogue ORDER BY text_ServiceDescription ASC; SELECT * FROM 3_serviceattributes WHERE bigint_AttributeServiceID = 1 ORDER BY text_AttributeDescription ASC; SELECT DISTINCT bigint_SupplierID FROM 4_servicesuppliers WHERE bigint_ServiceID = 1 ORDER BY bigint_SupplierID ASC; SELECT * FROM 5_suppliers WHERE bigint_SupplierID = 1 ORDER BY text_SupplierName ASC; SELECT DISTINCT bigint_RegionID FROM 4_servicesuppliers WHERE bigint_ServiceID = 1 ORDER BY bigint_RegionID ASC; SELECT * FROM 1_regions WHERE bigint_RegionID = 1 ORDER BY text_RegionDescription ASC; SELECT * FROM 1_regions WHERE bigint_ParentRegionID = 1 ORDER BY text_RegionDescription ASC; SELECT * FROM 1_regions WHERE bigint_ParentRegionID = 2 ORDER BY text_RegionDescription ASC; </sql></root> the javascript alertContents function i have sofar, follows below the format of the array passed to the addrecord() function that i'm trying to establish. i have been able to parse the supplier nodes and children, except of course the attribute nodes and children, which is why i am please asking for help, all i get passed is an array of 1,Test Service,20. // xml parserfunction alertContents() { if (http_request.readyState == 4) { if (http_request.status == 200) { var xmldoc = http_request.responseXML; // parse services var rows = xmldoc.getElementsByTagName("service"); for (var r = 0; r < rows.length; r++) { var i = 0; var arr = new Array(); for (var c = 0; c < rows[r].childNodes.length; c++) { var servicedetail = rows[r].childNodes[c]; if (servicedetail.childNodes.length > 0) { if (trim(servicedetail.firstChild.data) != "") { arr[i] = servicedetail.firstChild.data; i++; } } } // BEGIN SERVICE ATTRIBUTES ****************************** var attributes = rows[r].getElementsByTagName("attibute"); var x = 0; var arr1 = new Array(); for (var a = 0; a < attributes.length; a++) { var y = 0; var arr2 = new Array(); for (var aa = 0; aa < attributes[a].childNodes.length; aa++) { attribute = attributes[a].childNodes[aa]; if (attribute.childNodes.length > 0) { if (trim(attribute.firstChild.data) != "") { arr2[y] += attribute.firstChild.data; y++; } } } arr1[x] = arr2.join(";"); x++; } arr[i] = arr1.join("."); i++; // END SERVICE ATTRIBUTES ******************************** // service suppliers to come // service regions to come alert(arr); addrecord("list_services", arr); } //if (xmldoc.getElementsByTagName("sql")[0]) if (xmldoc.getElementsByTagName("sql")[0].firstChild) //var sql = xmldoc.getElementsByTagName("sql")[0].firstChild.data; if (sql != "") alert(sql); } else { alert('There was a problem with the request.'); } document.getElementById("ajaxbg").style.visibility = "hidden"; }} i know i'm not approaching the attribute tags correctly, but i might be close - i unfortunately have no clue how close or which way to go from now. i've literally hit the virtual horizon to horizon wall and can't see the bricks that are not there.many thanks in advance, even if its a nudge in the right direction - Pierre.
×
×
  • Create New...