Retreive Child-node's Data With DOM
May 17, 2005
Consider the following XML doc returned to the xmlHttpRequest obj:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<data>
<item id="1234">
<name>Test item 1</name>
<description>some text here</description>
</item>
<item id="1654">
<name>Test item 2</name>
<description>some text here</description>
</item>
</data>
How would I go about retreiving the item node's child element's data eg. "test item 1" ?
View 1 Replies
ADVERTISEMENT
Feb 23, 2011
I have two arrays. english() and french(), and each contain 10 quotes. I then have this HTML
Code:
<p><span class="pnum"> 1</span><span class="phrase"></span></p>
<p><span class="pnum"> 2</span><span class="phrase"></span></p>
<p><span class="pnum"> 3</span><span class="phrase"></span></p>
<p><span class="pnum"> 4</span><span class="phrase"></span></p>
<p><span class="pnum"> 5</span><span class="phrase"></span></p>
<p><span class="pnum"> 6</span><span class="phrase"></span></p>
<p><span class="pnum"> 7</span><span class="phrase"></span></p>
<p><span class="pnum"> 8</span><span class="phrase"></span></p>
<p><span class="pnum"> 9</span><span class="phrase"></span></p>
<p><span class="pnum">10</span><span class="phrase"></span></p>
Look at the comment in there to see what I need to do. I assume I would use .childNodes to get the end result, but I've never worked with nodes before, how would I reference the 2nd child (aka .phrase) and loop out the array in there?
Code:
function eventSource(e) {
var IE = document.attachEvent ? true:false;
var DOM = document.addEventListener ? true: false;
if (IE) return event.srcElement;
else if (DOM) return e.currentTarget;
}
function setUpTranslation() {
var phrases = document.getElementsByTagName("p");
for (var i=0; i < phrases.length; i++) {
//Here I need to reference the second child and change the inner content to french[i]
}}
View 5 Replies
View Related
Jul 23, 2005
There doesn't seem to be any mechanism to "clear" a node of all
it's children (not that its necessary very often, but I have come
across situations where I'd like to clear a node of all it's
children before appending other nodes). I've come up with two
possibilities: Code:
View 4 Replies
View Related
Dec 15, 2010
I'm currently working on a pretty straight-forward AJAX application. In this application, I get some XML, and then parse it. An example of what I'm working with is as such:
<?xml version="1.0"?>
<postRoot xml:lang="EN">
<post type="comment" date="January 1, 1970">
<user>athlon32</user>
<content>Hello World</content>
</post>
</postRoot>
Now, I've been able to read the XML with XMLHttpRequest , my trouble is with parsing the results. I've tried tons of things, but I just can't seem to get the different child nodes. Now, let's say we have something like this:
var xml = xhr.responseXML;
var allPosts = xml.getElementsByTagName('post');
Could I use childNode to access user & content? And if so, how? I've tried many things, but nothing is working :/ Is there a better way to parse the results I get back from the server?
View 1 Replies
View Related
Feb 2, 2011
I have been scratching my head on this one for a couple days:
Code:
function hideAll(){
var education = document.getElementById("education").childNodes;
[Code]....
As far as I know, this should be working the way I expect it to (set the display of all the childnodes to none), but I guess I'm missing something. Is it not possible to instantiate a variable using childNodes without choosing a specific index of the array? I just assumed it would work like any other array
View 7 Replies
View Related
Nov 21, 2010
I have this code that when links are clicked the elements are erased. The issue that I am facing is that I want to update the order of the attributes "id" and "var_id". Basically when you remove the first or the second element to update the order. I am not very savvy with DOM so I have hard time developing that functionality. I hope you guys can help me with that.
<html>
<head>
<script>
function removeElement_e(divNum)
{
var d = document.getElementById('e');
[Code]...
View 7 Replies
View Related
Mar 11, 2011
How can retreive the URLs from browsers history. My requirement is to show the links which user visited before visting my website as thumnails.
View 1 Replies
View Related
Apr 29, 2005
I am trying to pull two variables from a url and insert them into the appropriate text fields in a html form.
URL:
orderform.php?shape=Longboard&model=Cutter
I have this javascript, which searches the url string, HOWEVER it pulls the string into one variable. ie - Shape: LongboardCutter - INSTEAD OF: Shape: Longboard - Model: Cutter.
<script language="JavaScript">
document.form1.shape.value = location.search.substring(1);
</script>
[b]How do I get the javascript to pull the two variables seperately?[]
View 3 Replies
View Related
Apr 6, 2010
What's the best way to wrap all the nodes between two nodes in DIV tags? Is it possible with the DOM? I have code similar to the following:
HTML Code:
<h3>First header</h3>
<p>First paragraph</p>
<p>Second paragraph</p>
[code].....
How can I achieve this with the DOM, without resorting to doing something like a string replace?
View 2 Replies
View Related
Aug 6, 2010
Consider following html code
<p id="oliver">
<a id="oliver1" href="/oliver1/">Oliver Twist 1</a>
<a id="oliver2" href="/oliver2/">Oliver Twist 2</a>
<a id="oliver3" href="/oliver3/">Oliver Twist 3</a>
<a id="oliver4" href="/oliver4/">Oliver Twist 4</a>
</p>
Applying JavaScript to above html as following:
[Code]...
Why are anchor nodes pointing to href and text nodes pointing to [object]? As anchor and text both are objects therefore all outputs from indices 0 to 7 should be [object].
View 5 Replies
View Related
Aug 19, 2010
This div is the only div. Inside it has images that are clickable. I want to be able to first grab the left position of the elements and when they like a left arrow want to take this left number value and subtract it by a number and if the the right arrow is pressed then it will add a number to the left number value.Is this possible and if so how can I do this? I am guessing i can use the .css with the .child in jquery.
View 4 Replies
View Related
Sep 28, 2006
I am trying to pass user data from a parent window to a child window. I read somewhere that if i want to pass data as soon as child window opens i need to add a pause for the form elements to load. I am using the code snippet below.objf.form_parent.text1 is a text field in the parent window and newWindow.document.test.text1. is a field in child window. Can anyone help what I am doing wrong. Code:
View 2 Replies
View Related
Jun 1, 2011
I have two pages parent.html and child.html, the parent has a link called "Search", when clicked the child open in a modal centered window that has a search form, the search in the child return a list of rows, so when clicking a row the child window close and data is transferred to the parent.
View 1 Replies
View Related
May 23, 2010
I would like to have a main form (written in PHP) that has a "lookup" button next to a text field. When the user clicks "lookup", it should open a new window that lets them search (child.page1). When they enter a name or DOB into the search form, it submits the form through PHP (via POST), to a results page (child.page2). This displays all persons in the database which have a name or DOB == to the search term(s), with a checkbox next to each match. They click the checkbox (or alternenatively, a link), and return the checkbox value to the main window.
I have everything working right now, except that (child.page2) doesn't recognize the main window. If the data is entered on (child.page1), it works fine. I'm not very familiar with javascript.. is this even possible? I've considered using frames, to keep the parent-child relationship evident to the computer, but figured I'd check to see if there's an easier way.
View 4 Replies
View Related
Jan 26, 2011
I have 2 windows - parent and children.
in parent
<form name="calc" action="" method="post">
<input value="0" type="text" name="pay" id="pay">
</form>
in child
<form name="payment" action="" method="post">
<input value="0" type="text" name="pay_str" id="pay_str">
</form>
how can i transfer data from parent input to child input?
View 3 Replies
View Related
Feb 9, 2011
<div class="userbox posts" id="pst146996">
<div class="imgholder">
<img alt="Chris Hardin" src="http://codebix.com/bp/1633.png">
<div style="margin-left: 20px;" class="commentbox">
[code]....
i want already select .postlike in $(this) now i want to select the tagh1 who is in .commentboxelements.i want to change the h1's inside text 1 to 2 so i write the code
$(this).closest('.posts').children('.commentboxelements center h1').html('1');
i try this but it's not worked anyway how i can do this.
View 1 Replies
View Related
Jan 5, 2012
so i wrote this slider with some help from an admin, everything works as I would like it to but I'm trying to make it a plugin so i need to tighten up a certain part of the code:
(function( $ ){
$.fn.jmSlider = function() {
// get total width of all li elements in the slider
var wrapWidth = 0;
[code]....
what i would like to do is instead of using "li:first" and "li:last", i would like to use first-child and last-child so the element doesn't need to be a li, in can be anything that is the direct child of the parent container.
View 2 Replies
View Related
Oct 28, 2010
I have created parent child checkboxes. When one child is selected, then parent of that child, other child of same name and parent of that same name's child will be selected... Now I want if I unchecked any child, then only same name of child and parents should be unchecked or if I unchecked Parent Child, then same name of parent and child will be unchecked.
[Code]...
View 1 Replies
View Related
Nov 24, 2011
I have a difficult work around Jquery. I want to remove all li items from the ul except first li and last three li how to remove the li elements from these list.
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
[Code].....
View 1 Replies
View Related
Jul 23, 2005
I have a parent window that pushes a new window object onto an Array
with the following code :
OpenChild()
{
//totalNumWindowsCreated is global
totalNumWindowsCreated = totalNumWindowsCreated + 1;
childWnds.push(window.open(link, "child" +
totalNumWindowsCreated,"dependent"));
..
..
..
}
This pops up a new window with every call. In the child window I call
a parent function onbeforeunload, appClose() :
function appClose(){
if (window.opener && !window.opener.closed){
window.opener.CloseChild(getQueryString("application"));
}}
This is in my frameset tag of the child code :
<frameset ... onbeforeUnload='appClose()'>
The window.opener.CloseChild() function is called perfectly when I have
one child window open, but as soon as I create another child window
both of the open child windows don't ever call it. They do both go
into the onbeforeunload appClose() function, but do not call the
window.opener.CloseChild() function inside of this routine.
Anyone have any ideas why when I have two child windows open I can't
access the window.opener functions?
I have tried taking each new window out of the array and used the
following code in CloseChild() :
CloseChild()
{
//win and totalNumWindowsCreated are both global
totalNumWindowsCreated = totalNumWindowsCreated + 1;
var win = window.open(link, "child" +
totalNumWindowsCreated,"dependent");
..
..
..
}
View 1 Replies
View Related
Oct 22, 2010
I need to get the ID of all the nodes withing a DIV.
How do I do that?
View 1 Replies
View Related
Sep 1, 2005
is there a possibility to move a node from one child position to
another ?
View 4 Replies
View Related
Nov 1, 2007
I'm trying to iterate through nodes in a Selection Range, but I'm having a bit of trouble determining why all nodes in the range aren't being hit. It seems like deeply nested nodes aren't being hit for some reason.
Here's the code I'm using.
var n = startNode;
while (n) {
this.visited.push('[' + n.nodeName + ']');
if (n == endNode) {
break;
}
if (n != startNode && n.hasChildNodes()) {
n = n.firstChild;
} else {
while (!n.nextSibling) {
n = n.parentNode;
}
n = n.nextSibling;
}
}
View 1 Replies
View Related
Feb 17, 2011
I have two nodes with elements get by tag name.Now i want these two nodes merged in one node.ie:
list1 = document.getElementById("menu1").getElementsByTagName("a");
list2 = document.getElementById("menu2").getElementsByTagName("a");
View 14 Replies
View Related
Jul 23, 2005
I try to associate DOM nodes with other objects. Assigning custom
properties to DOM nodes works in Firefox and Safari. It also works with
HTML nodes in IE6. However, it appears not to work with XML nodes that
are part of trees returned by XMLHttpRequest. How can I work around this
limitation? For XML nodes, I need to be able to associate at most one
object with each node.
The syntax I am using is
node.customproperty = value
View 2 Replies
View Related
Feb 8, 2007
I must be missing something very obvious, but my nightly head doesn't work anymore.
Press "Insert" button to add <insnodes after each <br>. Now press "Delete" - only even <insare being removed. ins.length is reported properly, each <inshas "insert" class name. What a...?
View 6 Replies
View Related