JavaScript - <br> With Undefined Parent Node.
In order to better understand the DOM data structure, I am trying to write a JavaScript that will produce something like HTML from the DOM data structure.
My current problem is that when I include a <br> tag in my source HTML, it reports that its parent is undefined, and this is breaking my code. So, given the following code, why does the <br> tag report that it's parent is undefined. Code: <html> <head> <title>br.parent</title> <script type="text/javascript"> function brTest() { var jBR = document.getElementsByTagName("br")[0]; alert("<br>.nodeType = " + jBR.nodeType + "\n<br>.nodeName = " + jBR.nodeName + "\n<br>.ParentNode = " + jBR.ParentNode); } </script> </head> <body onload = "brTest();"> <p>Now is <br> the time.</p> </body> </html> Thanks for any help you can provide. Jerry Similar TutorialsHi, im having a little difficulty checking if an XML node has a value, here the code: var Divs=new Array("artist","bio","img","date","tickets","venue","street","city","country","headliner"); xmlDoc=xmlhttp.responseXML; for ( nodes in Divs ) { if(!xmlDoc.getElementsByTagName(Divs[nodes])[0].childNodes[0].nodeValue) { } else { document.getElementById(Divs[nodes]).innerHTML= xmlDoc.getElementsByTagName(Divs[nodes])[0].childNodes[0].nodeValue+"<br>"; } } This always throws up the error: document.getElementById(Divs[nodes]) is null ive tried putting the xmlDoc in a variable then checking if its null but no luck, also tried the same method against "undefined" but no luck either. Would be greatful if anyone has any suggestions. Thanks, Tom. For a widget I made, I have a dropdown select menu. It is constrained to a very small width and IE does not auto expand on click. I wrote a simple javascript to handle this but I run into two problems. The onmouseout function is fired when I click into a child node, and the onmousedown of the <option> tags doesn't work in IE. The code works fine in all other browsers. var wid; var campaign_i = 0; function campaignWidget_capture(myID){ wid=document.getElementById(myID).style.width; campaign_i++; } function campaignWidget_SubDes(myID,state){ if(state==0){ if(campaign_i==0) campaignWidget_capture(myID); document.getElementById(myID).style.width="auto"; }else document.getElementById(myID).style.width=wid; } onmouseout="campaignWidget_SubDes(id,1)" This is in the select tag. onmousedown="campaignWidget_SubDes(id,0)" This is in the select tag onmousedown="campaignWidget_SubDes('campaignWidget_Sub_Designation',1)" This is in the option tag. Hello all, I have a page which has a form and also one iframe in the same. there is a button on the parent form. when the button is clicked, i am submitting the iframe and parent both. forms are getting submitted. but when i do print_r for iframe values, it is blank below is the code Parent page: Code: <? print "<pre>"; print_r($_POST); print "</pre>"; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> </HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- function validate(){ document.getElementById('mainform').submit(); window.frames['iframe1'].document.forms[0].submit(); } //--> </SCRIPT> <BODY> <FORM METHOD=POST ACTION="" name='mainform' id='mainform'> <TABLE> <TR> <TD>Name</TD> <TD><INPUT TYPE="text" NAME="Name_VC"></TD> </TR> <TR> <TD>Address</TD> <TD><INPUT TYPE="text" NAME="Address_VC"></TD> </TR> <TR> <TD colspan=2><INPUT TYPE="button" name="proceed" value="Save" onClick="validate();"></TD> </TR> </TABLE> </FORM> <iframe src="test1.php" id='iframe1'></iframe> </BODY> </HTML> iframe page : test1.php Code: <? print "<pre>"; print_r($POST); print "</pre>"; ?> <form name='mainform2' id='mainform2' method='post' action=''> Roll number : <INPUT TYPE="text" NAME="Rollnum" value=''> Age: <INPUT TYPE="text" NAME="Age_IN" value=''> </form> Please tell me what is my mistake or how can i achieve values of all 4 fields Million thanks I just really needed to know something about the whitespace between nodes in a tree structure. I know that Firefox's, Safari's, Chrome's and Opera's DOM treat the whitespace as a node. I am wondering what nodeType whitespace would return? Thank you all for any help + sugestions. can someone please help me to find out wahy I cant access the text value within the "author> tag using the following code? I get that "var y" is null. Thanks! Code: Content-type: text/html\n\n <html> <body> <book> <author>Moris</author> </book> <script type="text/javascript"> var x =document.getElementsByTagName("author")[0] var y = x.childNodes[0]; document.write(y.value) </script> </body> </html> i was wondering: Has anyone here has used Node.js on a production service, app, or site ? If so, what type of project was it, and how is it working out? I'm building a new media site at work using node, and have been blown away by what i've seen/tested so far. Swapping the LAMP stack for just linux and js has really opened my eyes to just how wrong i had been approaching the back-end for so long. Does anyone else have this experience, or am i the only one getting 1,000X performance increases with node? try serving half a million dynamic pages in one hour at 10% cpu and <20 megs of ram on a 5-year old compaq consumer desktop using php; i dare you... i guess the main question is that it's so literally awesome on the bench, will those number hold once it starts getting used by the public? edit: I further identified the problem. Hi, I'm new to JavaScript and I'm having problem with appending a div node returned from a function. Here's where it crashed: Code: var div=document.getElementById("dashboard_secondary_cat_list"); var s=get_secondary_cat_node(attributes); alert("b4 appendin:"+s); div.appendChild(s); alert("done appendin"); alert("done appendin"); never gets called because the previous line crashes. alert("b4 appendin:"+s); shows: b4 appendin:[object HTMLDivElement] Does anyone know of a good tutorial on how to make a good node.js chat? I need a chat that a decent VPS server can handle ~100 simultaneous users with and apparently I should be using node.js but have no experience with it. What should I look at? Thanks! Hello I am trying to iterate out the values of an xml file. I have got the file to load though I have not yet been able to extract the values. Considering that theXml is an xml file and 'coords' are tags containing a coordinate how would I extract the value. Here is the code I am using Code: var coordTags = theXml.getElementsByTagName( 'coords' ); var len =coordTags.length;///this works var coord =coordTags[0].value;///this doesn't work var coord =coordTags[0].text;///this doesn't work var coord =coordTags[0].innerText;///this doesn't work parent.document.receiver.theres.value = coord; I am sure for some of you this is a really simple question so please someone help!! Hi follks, i have a xml like this <t> <country>usa</country> <country>india</country> <country>china</country> <country>russia</country> <country>mexico</country> </t> im passing the node country alone in javascript function js:findcountry(//country) the function is like this findcountry(xmlnodecountry) { } what code i should use to send the node country alone to the javascript function. and how can i read and traverse thru the nodes i used xmlnodecountry.selectnodes but it didnt work. im not getting the node itself in xmlnodecountry I'm beginner, and there is a task in exam to change inner content of the second child node. Can't get, please help or maybe link to an article how to do it, because I can't find anything in my study book; edit: is this correct? function SetUpTranslation() { var phrases = document.getElementsByTagName('p'); for (var i=0; i < p.attributes.length; i++){ phrases.secondNode.innerHTML=french[i]; element.onclick=swapFE(phrases.secondNode); element.onmouseup=swapFE(phrases.secondNode); } } Hey guys..... I've worked out how to get the value from a select option tag, but can't work out how to get the text inside the option tags. Here is the code I am using to get the value attribute from the option tag.. PHP Code: // Set the search results box var cats = document.getElementById('cat_list'); // Loop through categories from the search results select box for (i = 0; i < cats.length; i++) { // Check if the cat is selected if (cats.childNodes[i].selected == true) { // Set this category's values to some variables var cat_id = cats.childNodes[i].getAttribute('value'); } } Thanks! Hey, guys, my first post here on the forums, I hope this is the right place. This technically uses Javascript + PHP + XML, but the problem is more based on Javascript than the other two. That, and there are 380 people viewing Javascript and 8 people viewing XML, I decided to take the path of lesser resistance. Also, the code I used, I'm sure there are a million shortcuts that could be used. So if you can give me suggestions, I would Love to hear them because I'm still learning Javascript + PHP + XML and would be very grateful to learn how I could be more efficient What I'm creating is a Form that takes variables from an XML for users to fill out. Users can choose between products, and then when the product is clicked, it loads the options from an Array within the XML so... The question is Products Load from an Array Options Load from the chosen Products? I'm thinking this can be done two ways. Maybe a separate XML can be used for Options but then how would I link each one for each product? Or, can I load the Options in the same XML for each Product and load an array for each Product's Options? --- Later on, I need to figure out how to create a new element for each form the User fills out. IE They finish filling out the options and volume for 20 GI JOES. So it should save those Variables and the User Filled Variables. And then allow you to fill out a new product. Appending to the last form filled out IE 20 GI JOES [Color Red] [Eating Pizza] [Wearing Cowsuits] 12 BARBIES [Color Blue] [Eating Sushi] [Wearing Bearsuits] But I'll do my own reearch for that before I start asking here on how to do that --- This is my Code so far, some of you will recognize it from W3 Schools --- Code: JS oldTextAry = new Array(); var xmlDoc; if (window.XMLHttpRequest) { xmlDoc=new window.XMLHttpRequest(); xmlDoc.open("GET","data.xml",false); xmlDoc.send(""); xmlDoc=xmlDoc.responseXML; } else if (ActiveXObject("Microsoft.XMLDOM")) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc.load("data.xml"); } var x=xmlDoc.getElementsByTagName("PR");i=0; var y=xmlDoc.getElementsByTagName("OPTION");j=0; var z=xmlDoc.getElementsByTagName("OPT");k=0; var enl; Above Code, calls on data.xml in the same folder. It then creates an array from the XML for <PR> <OPTION> and <OPT>. In the XML. It's... Code: XML <PRODUCT> <PR> <TITLE>Title goes here</TITLE> <IMG>jpg html for image goes here</IMG> <ENL>jpg html for high res image goes here</ENL> <LINK>a link if needed</LINK> <INFO>more info if needed</INFO> <OPTION> <OPT>hearts</OPT> <OPT>stars</OPT> <OPT>horseshoes</OPT> <OPT>clovers</OPT> <OPT>balloons</OPT> </OPTION> </PR> <PR> <TITLE>Title goes here</TITLE> <IMG>jpg html for image goes here</IMG> <ENL>jpg html for high res image goes here</ENL> <LINK>a link if needed</LINK> <INFO>more info if needed</INFO> <OPTION> <OPT>hearts</OPT> <OPT>stars</OPT> <OPT>horseshoes</OPT> <OPT>clovers</OPT> <OPT>balloons</OPT> </OPTION> </PR></PRODUCT> The OPT is what I want to load as an array. How could I do that? So continuing with the JS code... Code: function productnext(){if (i<x.length-5) { i++; productline();return false; }} function productprevious(){if (i>0) { i--; productline();return false; }} function productline(){ ttl1=(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue); ttl2=(x[i+1].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue); ttl3=(x[i+2].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue); ttl4=(x[i+3].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue); ttl5=(x[i+4].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue); img1=(x[i].getElementsByTagName("IMG")[0].childNodes[0].nodeValue); img2=(x[i+1].getElementsByTagName("IMG")[0].childNodes[0].nodeValue); img3=(x[i+2].getElementsByTagName("IMG")[0].childNodes[0].nodeValue); img4=(x[i+3].getElementsByTagName("IMG")[0].childNodes[0].nodeValue); img5=(x[i+4].getElementsByTagName("IMG")[0].childNodes[0].nodeValue); lnk1=(x[i].getElementsByTagName("LINK")[0].childNodes[0].nodeValue); lnk2=(x[i+1].getElementsByTagName("LINK")[0].childNodes[0].nodeValue); lnk3=(x[i+2].getElementsByTagName("LINK")[0].childNodes[0].nodeValue); lnk4=(x[i+3].getElementsByTagName("LINK")[0].childNodes[0].nodeValue); lnk5=(x[i+4].getElementsByTagName("LINK")[0].childNodes[0].nodeValue); inf1=(x[i].getElementsByTagName("INFO")[0].childNodes[0].nodeValue); inf2=(x[i+1].getElementsByTagName("INFO")[0].childNodes[0].nodeValue); inf3=(x[i+2].getElementsByTagName("INFO")[0].childNodes[0].nodeValue); inf4=(x[i+3].getElementsByTagName("INFO")[0].childNodes[0].nodeValue); inf5=(x[i+4].getElementsByTagName("INFO")[0].childNodes[0].nodeValue); opt1=(y[j].getElementsByTagName("OPT")[0].childNodes[0].nodeValue); opt2=(y[j+1].getElementsByTagName("OPT")[1].childNodes[0].nodeValue); opt3=(y[j+2].getElementsByTagName("OPT")[2].childNodes[0].nodeValue); opt4=(y[j+3].getElementsByTagName("OPT")[3].childNodes[0].nodeValue); opt5=(y[j+4].getElementsByTagName("OPT")[4].childNodes[0].nodeValue); enl1=(x[i].getElementsByTagName("ENL")[0].childNodes[0].nodeValue); enl2=(x[i+1].getElementsByTagName("ENL")[0].childNodes[0].nodeValue); enl3=(x[i+2].getElementsByTagName("ENL")[0].childNodes[0].nodeValue); enl4=(x[i+3].getElementsByTagName("ENL")[0].childNodes[0].nodeValue); enl5=(x[i+4].getElementsByTagName("ENL")[0].childNodes[0].nodeValue); The first two functions are for a list in the PHP. The rest of the code gives the first five products into respective variables for the PHP to use. Code: PHP <td width="25" rowspan="3"><a title="<b>Previous Product</b><br><br>Click to Scroll the product list left" onclick="productprevious();" style="cursor:pointer"><img src='prodprev.jpg' width="25" height="170"></a></td> <td> </td> <td width="120" height="120" valign="top"><div id='PR1'></div></td> <td> </td> <td width="120" height="120" valign="top"><div id='PR2'></div></td> <td> </td> <td width="120" height="120" valign="top"><div id='PR3'></div></td> <td> </td> <td width="120" height="120" valign="top"><div id='PR4'></div></td> <td> </td> <td width="120" height="120" valign="top"><div id='PR5'></div></td> <td> </td> <td width="25" rowspan="3"><a title="<b>Next Product</b><br><br>Click to Scroll the product list right" onclick="productnext();" style="cursor:pointer"><img src='prodnext.jpg' width="25" height="170"></a></td> It's a line for five products. When people hit the Next button, it moves the Array one product over. And previous button does vice versa. Code: JS document.getElementById("PR1").innerHTML="<a href='javascript:void();' onClick='picture1();'><img src='"+img1+"' height=120 width=120></a>"; document.getElementById("PR2").innerHTML="<a href='javascript:void();' onClick='picture2();'><img src='"+img2+"' height=120 width=120></a>"; document.getElementById("PR3").innerHTML="<a href='javascript:void();' onClick='picture3();'><img src='"+img3+"' height=120 width=120></a>"; document.getElementById("PR4").innerHTML="<a href='javascript:void();' onClick='picture4();'><img src='"+img4+"' height=120 width=120></a>"; document.getElementById("PR5").innerHTML="<a href='javascript:void();' onClick='picture5();'><img src='"+img5+"' height=120 width=120></a>"; document.getElementById("PT1").innerHTML="<a href='javascript:void();' onClick='picture1();'>"+ttl1+"</a>"; document.getElementById("PT2").innerHTML="<a href='javascript:void();' onClick='picture2();'>"+ttl2+"</a>"; document.getElementById("PT3").innerHTML="<a href='javascript:void();' onClick='picture3();'>"+ttl3+"</a>"; document.getElementById("PT4").innerHTML="<a href='javascript:void();' onClick='picture4();'>"+ttl4+"</a>"; document.getElementById("PT5").innerHTML="<a href='javascript:void();' onClick='picture5();'>"+ttl5+"</a>"; return false;} This code places the products into the respective list. PR1 gets IMG1. This is also where I wonder if it could be more efficient, because I'm copying things five times in a row. There's got to be a better way to do that. Whenever it's clicked it operates a function called picture#() corresponding to the button. Once again... Must be a more efficient way. Code: function picture1() {document.getElementById('PI').innerHTML="<img src="+img1+" height=170 width=170>";document.getElementById('PTT').innerHTML=ttl1; /*test area, delete when done*/enl=enl1;document.getElementById("E").innerHTML=enl;} function picture2() {document.getElementById('PI').innerHTML="<img src="+img2+" height=170 width=170>";document.getElementById('PTT').innerHTML=ttl2; /*test area, delete when done*/enl=enl2;document.getElementById("E").innerHTML=enl;} function picture3() {document.getElementById('PI').innerHTML="<img src="+img3+" height=170 width=170>";document.getElementById('PTT').innerHTML=ttl3; /*test area, delete when done*/enl=enl3;document.getElementById("E").innerHTML=enl;} function picture4() {document.getElementById('PI').innerHTML="<img src="+img4+" height=170 width=170>";document.getElementById('PTT').innerHTML=ttl4; /*test area, delete when done*/enl=enl4;document.getElementById("E").innerHTML=enl;} function picture5() {document.getElementById('PI').innerHTML="<img src="+img5+" height=170 width=170>";document.getElementById('PTT').innerHTML=ttl5; /*test area, delete when done*/enl=enl5;document.getElementById("E").innerHTML=enl;} Above, places that picture into "PI" and gets the title and places it into "PTT" --- I was hoping to create another list. EXACTLY like I have here. Where the User can hit Next and Previous, using Options Loaded from an Array within the Array of Products. Is making a new XML with options the only way to do this? If that's the case, how do I associate each product with their options? Allow the search function to start anywhere within the name, rather than just at the start (so searching for "icha" would match "Richard". If more than 3 matches are found during the search don't display them just inform the user of the number of matches and suggest they search more precisely. Every time the user enters a "bad command", informs them of how many more they are allowed before they are locked out of the system. Introduce and implement an option to change a user's phone number. Reply With Quote 01-14-2015, 08:34 PM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,311 Thanks 82 Thanked 4,754 Times in 4,716 Posts Look he http://www.codingforums.com/rules.htm And read rule 1.5 We do *NOT* do your homework for you. I will bet that the answer you got for "search array string" is too advanced. That is, your instructor will know immediately that it is not your own work. You need to *TRY* to do your homework yourself. If you get stuck on one particular point, where your code almost works but not quite, *THEN* is the time to ask a question. But you need to show your work so far. And, if you can, explain what is not working. ********* On a side note: How the heck is anyone here supposed to be able to help you with this part of the homework: Every time the user enters a "bad command", informs them ... You haven't even told us what a "command" is! If you *are* going to ask for help, you have to give enough information that someone can understand the question. But, again, don't expect help until you can (for example) at least show that your code is TRYING to process a "command". Same applies to Introduce and implement an option to change a user's phone number. You haven't bothered to show the data structure that even *HAS* phone numbers in it! Talk about incomplete information! Hi I discovered something weird that happend to me when trying to add a javascript created table to the document.body. Basically it doesn't add it in IE, but works fine in FF. Actually it does add it in IE, but only shows up if I add a <br/> later in a new statement... What?!?! try my code to see what is going on. (works fine in FF, does bad thing in IE) I tried to narrow the code i was working with down to basics and still have the glitch happen so maybe it's just something wrong with this code, but i couldn't pinpoint it. Also, it's only when i do document.body.appendChild(), not document.body.innerHTML += entireMassiveElement.innerHTML; I need it to work in both browsers with the appendChild() method, because innerHTML is much slower. Any advice appreciated! Thanks! 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>Interace v1.0</title> <style type="text/css"> /****************** * --Panel Style ******************/ .panel { } .panel table td {padding: 0px;} .panel_corner { background-color: #00c0ff; background-repeat: no-repeat; width: 3px; height: 3px; } .panel_sideX {height: 3px; background-color: #00c0ff; background-repeat: repeat-x;} .panel_sideY {width: 3px; background-color: #00c0ff; background-repeat: repeat-y;} .panel_topLeft {background-position: 0px 0px;} .panel_topRight {background-position: -3px 0px;} .panel_bottomLeft {background-position: -0px -3px;} .panel_bottomRight {background-position: -3px -3px;} .panel_top {background-position: -3px -6px;} .panel_right {background-position: -3px 0px;} .panel_left {background-position: 0px 0px;} .panel_bottom {background-position: -3px -9px;} .panel_main { background-color: #00c0ff; } .panel_titlebar { color: #ffffff; font-family: verdana; font-size: 10pt; padding: 3px; padding-top: 0px; overflow: hidden; /* display: none; */ } .panel_title { float: left; height: 18px; overflow: hidden; } .panel_buttons { float: right; } .panel_toolbar { background-color: #444444; color: #eeeeee; font-family: verdana; font-size: 10pt; padding: 3px; overflow: hidden; display: none; } .panel_content { overflow: auto; font-family: arial; color: #eeeeee; font-size: 7pt; font-weight: bold; padding: 10px; border: 1px inset #cccccc; background-color: #444444; } </style> <!--///////////////////////////////////--> <script type="text/javascript"> function makeElement() { var layout = document.createElement("table"); //the table that is the basic layout var top = document.createElement("tr"); var tl = document.createElement("td"); top.appendChild(tl); var tc = document.createElement("td"); top.appendChild(tc); var tr = document.createElement("td"); top.appendChild(tr); var middle = document.createElement("tr"); var ml = document.createElement("td"); middle.appendChild(ml); var mc = document.createElement("td"); middle.appendChild(mc); var mr = document.createElement("td"); middle.appendChild(mr); var bottom = document.createElement("tr"); var bl = document.createElement("td"); bottom.appendChild(bl); var bc = document.createElement("td"); bottom.appendChild(bc); var br = document.createElement("td"); bottom.appendChild(br); layout.appendChild(top); layout.appendChild(middle); layout.appendChild(bottom); layout.style.borderCollapse = "collapse"; tl.className = "panel_corner panel_topLeft"; tc.className = "panel_sideX panel_top"; tr.className = "panel_corner panel_topRight"; tl.style.padding = "0px"; tc.style.padding = "0px"; tr.style.padding = "0px"; ml.className = "panel_sideY panel_left"; mc.className = ""; mr.className = "panel_sideY panel_right"; ml.style.padding = "0px"; mc.style.padding = "0px"; mr.style.padding = "0px"; bl.className = "panel_corner panel_bottomLeft"; bc.className = "panel_sideX panel_bottom"; br.className = "panel_corner panel_bottomRight"; bl.style.padding = "0px"; bc.style.padding = "0px"; br.style.padding = "0px"; //-- Set up the cursors for the bottom, right, and bottomright sides to resize mr.style.cursor = "e-resize"; bc.style.cursor = "s-resize"; // --Now create the internal structure, titlebar, toolbar, content area var main = document.createElement("div"); var titlebar = document.createElement("div"); var toolbar = document.createElement("div"); var content = document.createElement("div"); content.innerHTML = "success!"; main.appendChild(titlebar); main.appendChild(toolbar); main.appendChild(content); mc.appendChild(main); main.className = "panel_main"; titlebar.className = "panel_titlebar"; toolbar.className = "panel_toolbar"; content.className = "panel_content"; //-- create the titlebar internals, title, buttons, cleardiv var title = document.createElement("div"); var buttons = document.createElement("div"); var clear = document.createElement("div"); titlebar.appendChild(title); titlebar.appendChild(buttons); titlebar.appendChild(clear); clear.style.clear = "both"; title.className = "panel_title"; buttons.className = "panel_buttons"; main.style.width = "200px"; return layout; } function go(select) { var stuff = makeElement(); if(select == 1) { //-- Add everything to the container document.body.appendChild(stuff); } else if (select == 2) { //-- Add everything to the container //layout is a table, but innerHTML only returns the inner, so i just added on the outer tags. document.body.innerHTML += ('<table cellpadding="0" cellspacing="0">' + stuff.innerHTML + '</table>'); } //document.body.innerHTML += "<br/>"; } </script> </head> <body> <input type="button" value="test append Element" onclick="go(1);"/><input type="button" value="test innerHTML add" onclick="go(2);"/> <body> </html> I'm having a bit of a problem processing an OPML file to load into a list widget that's included in the WebOS development kit. Say I have an OPML file like: Code: <opml version="1"> <head> <title>News</title> </head> <body> <outline text="Local News" key="local"> <outline type="link" text="Some local Blog1" URL="http://local1.com"/> <outline type="link" text="Some local Blog2" URL="http://local2.com"/> </outline> <outline text="National News" key="national"> <outline type="link" text="Some national Blog1" URL="http://national1.com"/> <outline type="link" text="Some national Blog2" URL="http://national2.com"/> </outline> <outline type="story" text="Community" URL="http://directlinktostory1.com"/> <outline type="link" text="Classifieds" URL="http://directlinktostory2.com"/> <outline type="link" text="Download More News" URL="http://newsfeed.com/getmore.ashx"/> </body> </opml> I can put each text attribute into the list widget using: Code: var tree = transport.responseXML.getElementsByTagName('outline'); for( var i = 0; i < tree.length; i++ ) { curr = tree[i]; if (!curr.hasChildNodes){ this.title = curr.getAttribute('text'); } this.category_items.push({text: this.title}); } But, what I'd like to do is divide the list into categories. To do this, I'd need to append the text attribute value of the parent node to each of the child nodes under the parent node, and in the process, tell it to push the text attribute values of the childnodes if they exist, and of the parentnodes if they do not have childnodes. So I'd be left with something looking like: Code: Local News: Some local Blog1 Some local Blog2 National News: Some National Blog1 Some National Blog2 Misc: Community Classifieds Download More News I'd also like to be able to compare the value of an attribute such as "Download More News" and have that perform a specific function. Can somebody please point me to some information on grabbing only childnodes where they exist and also comparing the value of an attribute to a string? Thank you, Doc Hello everyone, I have a page. In that page is an iframe, lets name it 'A'. inside A there is another iframe 'B'. there is a link on that page which on click opens a popup. In that pop up, there is actually a document upload facility. Now i want that after every upload (onSubmit), iframe A should refresh. have done it many times but today its not working. Code: function validate() { (window.parent.opener.location.href)=(window.parent.opener.location.href); window.parent.opener.location.reload(true);// this is tried as well } Can some one please help. it always refreshes only B. Thanks Hi, I'm very new to javascript and don't really ask questions in forums because i usually find what I'm looking for in other threads. I have a situation where I open a popup window from what I'll call "the main page", insert some text and open a 2nd popup from there. After making a selection, that window closes to bring the 1st popup back to focus. When I submit the form in that window, some info is changed in a database. How can I refresh or reload the main page to show the changes? Is the "main page" still the opener after opening and closing windows?
Hi guys, new to javascript and need some basic help or advice. I have this code which changes the the background postion of the parent(ul) Code: <ul> <li class="highways" onmouseover="if(this.parentNode) this.parentNode.style.background='transparent url(http://www.webaddress.co.uk/website/media/images/Sub_nav_img.jpg) no-repeat 0 -149px';" onmouseout="if(this.parentNode) this.parentNode.style.background='transparent url(http://www.webaddress.co.uk/website/media/images/Sub_nav_img.jpg) no-repeat 0 0';"><a href=" " title="Highways">Highways</a></li> </li> </ul> I would like to do the same thing change the backgroundpossition/images of the div (id="flash") on the hover of the a within the the (div="mySlides2" > div ) Code: <div id="flash"> <img src="images/img1.jpg" width="886" height="229" /> <div id="myController2"> <span class="jFlowControl2">No 1 </span> <span class="jFlowControl2">No 2 </span> </div> <div id="mySlides2"> <div> <a (would like to do somthing on the hover of this) class="vm" href="#" title="Vulnerability Management"></a> <a class="grc" href="#" title="grc"></a> <a class="pci" href="#" title="pci"></a> <a class="gcs" href="#" title="gcs"></a> <a class<div id="flash"> <img src="im="pt" href="#" title="Penetration Testing"> </a> <span class="jFlowNext2 NextFlash"> </span> </div> <div> <span class="jFlowPrev2 BackFlash"> </span> </div> </div> </div> any help of advice would b appricated Dear Great Coders, I am having some trouble to get the id of the parent of a document which is iframe1 here. As you can see it the <javascript> is residing in the javascript section. Do mind giving me some ideas? Yes, I know. I can insert the javascript on the top, but believe me i cant for some purpose because I am intergrating many other codes into it. <html> <iframe id="iframe1"> <html> <head> <javascript> </head> <body> </body> </html> </iframe> </html> |