Get Tag Name Loop?

Feb 7, 2010

I am using the code below to get the number of trs in the tbody.

This works fine when there is only one tbody within my code. How can I adapt it so if there are multiple tbody's then it will actually only return the first one and return all the trs across all of them? (The other tbody's will actually be embedded within the first tbody). I dont think that is valid html but the script I am using requires that unfortunatly.

Code:
nTrs = oSettings.nTable.getElementsByTagName('tbody')[0].childNodes

View 2 Replies


ADVERTISEMENT

Recursive Function With For Loop, For Loop Is Breaking When Calling Itself

Jan 22, 2011

I have been looking at this code for two evenings now, and rewrote it 4 times already. It started out as jQuery code and now it's just concatenating strings together.

What I'm trying to do: Build a menu/outline using unordered lists from a multidimensional array.

What is happening: Inside the buildMenuHTML function, if I call buildMenuHTML, the for loop only happens once (i.e. only for 'i' having a value of '0'.) If I comment out the call to itself, it goes through the for loop all 3 times, but obviously the submenus are not created.

Here is the test object:

test = [
{
"name" : "Menu 1",
"url" : "menu1.html",
"submenu" : [

[Code].....

'Menu 2' and 'Menu 3' don't show up! I'm sure it's something small that I'm overlooking.

View 2 Replies View Related

Send A Loop Variable (i) To A Function Inside The Loop

Aug 4, 2011

I'm looking to send a loop variable (i) to a function inside the loop, but I can't seem to get it to use the value I want, it keeps making it a reference of i and therefore the function is always called using the last value of i rather than the one it was set with.

So if i have 5 Tabs then Tab 1, when clicked, should call DefaultTabClick(0) and so on rather than always using 4 for any of the tabs.

View 2 Replies View Related

JQuery :: Loop Forever And Reload Xml Each Loop?

Jul 29, 2011

I have the code below, how could it be modified to loop over and over and reload the xml file each time. Flow would be: load xml, run thruogh code to display each xml node one at a time, when reach last node, start all over, reloading xml file,

[Code]...

View 2 Replies View Related

While Loop Or For Loop For This Script Involving Arrays?

Mar 6, 2011

As you can see from the code and the output, it will attempt to write to the browser how many moves, but only '0'.

function rollDie()
{
return Math.floor(Math.random() * 6) + 1;
}
/*
*searches for a number in a number array.
*
*function takes two arguments[CODE]...

View 5 Replies View Related

Changing For Loop To While Loop?

Nov 12, 2010

I am doing some studying and we was to create a small loop using either the for loop, while loop or do while loop. I chose to do the for loop because it was easier to understand, but I want to know how to do the same using the while loop. Here is the for loop I have, but I cant figure out how to change to while loop.

for (var i = 0; i < 5; ++i)
{
for (var j = i; j < 5; ++j)
{

[Code]....

How do you make the same using a while loop?

View 2 Replies View Related

For Loop Wont Loop?

Jul 5, 2010

it wont loop,as long as you enter something in the name field it will submit. also how do i stop from submitting if all fields are not filled out?

function checkForm(form)
{
var len = form.elements.length;[code]....

View 3 Replies View Related

Do While Loop

May 8, 2007

I am trying to make a program that either alerts or at least prints the multiples of a number (which the user inputs into a text field). I am required to use a do while loop for this, so here is what I have so far. Code:

View 1 Replies View Related

How To Loop Through Forms?

Jul 23, 2005

Using DOM in IE, how can I loop through FORMs and access FORM elements
in a specific form? For example, www.hotmail.com has about 13 forms.
I believe the one displayed is dependent on the URL. If I want to
access the submit button of the visible form, which is usually the last
one, how is that done?

Currently, I look for type=submit using DOM but it doesn't find
anything and only loops through the first FORM elements.

View 3 Replies View Related

Loop Through Checkboxes

Jul 20, 2005

Browser: IE5+

I have a form with an unknown number of checkboxes (the page is generated
by a server-side script). I need to loop through those checkboxes, test
whether the name of each checkbox starts with a known string and, if it
does, clear that checkbox.

I've tried just about everything that I can think of, but to no avail.

Can someone tell me how to loop through the checkboxes of a form?

View 1 Replies View Related

Is It Possible To Loop Through All Objects?

Jul 20, 2005

If you have a javascript interpreter running in an environment unknown
to you (as in what objects it exposes to the language) is it possible
to loop through all objects in some way?

This is a non-browser environment, specifically the scripting engine
for doing xslt extensions in msxml.

View 1 Replies View Related

Put PHP Loop On A InnerHTML?

Aug 30, 2011

so I have this code for a date form and I made a PHP loop and even a javascript loop for it. There is a script that supposedly adds multiple 'dates' when the user clicks this 'add more date' button and I use an innerHTML to clone it.

My problem is how will I put it inside an innerHTML on a javascript. Since innerHTML reads html tags, is it possible to put a PHP loop within it? and how will you also call a javascript function within it?

this is the PHP code:
<select>
<?php
for ($i=date("Y"); $i>=1950; $i--)

[Code]....

I just need to know if what im doing is right, or is there another way to do this?

View 4 Replies View Related

Loop Through Table IDs?

Apr 27, 2009

I have a PHP script that generates a large, tree structured, table from XML data.Depending on user input, I need to expand or collapse sections of the table (Show/Hide).The way I have written the PHP script, each row is labelled with an "id=" according to its tree position.e.g. block0, block0_0, block0_1, block1, block1_2_0, etc. The buttons for each branch of the tree call a Javascript function, e.g. onclick="return toggleMe('block1')" or onclick="return toggleMe('block2_0_1')", and the toggleMe function knows it has to Show/Hide every row who's id starts with that string. Each row has a unique id, just incrementing the last digit.My problem is that I do not know how many rows there are and what I want to do is to loop through all the rows and see if their id starts with the parameter sent to the function.

View 2 Replies View Related

Increment Var By 1 In Loop?

Apr 6, 2009

I have a loop that is running and I am trying to increment a number by one each time. Here is what I am doing, but each time it just writes out 1 for the value.

var i=1;
Start of Loop
document.write(i);
var i=i++;
End of loop

It just writes out 1 each time though.

View 4 Replies View Related

Loop An Animation With Js?

Apr 8, 2009

How can I loop the animated object with javascript?

here is the code I managed to achieve so far code...

View 1 Replies View Related

Using Variable In A Loop?

Dec 15, 2009

I have a lot of variables (lab0, lab1, lab2, ...). How can I use these vaiable in a loop. Javascript thinks it is a variable 'labi'.

for ( var i=0;i<10; i++ )
{
f1.path.op[i].value = f1.labi.value;
}

[code]...

View 6 Replies View Related

Get The .wav File To Loop?

Feb 23, 2010

I have used a script in my site but would like to get the .wav file to loop can anyone advise how to change the script to allow this, I am not very good with Javascript! Here is the Javascript:

<!-- Functions Code Block Start-->
<script>
/* Here we are creating two functions. The first to start a sound object playing and the second to stop a sound object from playing. */
//
// This function, when called will play the sound object
function EvalSoundPlay(soundobj) {
[Code]...

View 5 Replies View Related

Loop Elements By Name?

Sep 14, 2010

Ok so I have these elements on my page:

<input type="text" size="5" name="val[]" value="'.$NotaMaxima.'">

I want to loop through each one and take their number add it to another number set in a variable elsewhere and then alert that number.The amount of these elements on the page changes constantly, so I can't count on that. It has to loop through each one to find the values.I tried this:

var els,i,asig;
els=document.getElementsByTagName('val');
for(i in els) {[code]..........

View 3 Replies View Related

Add Two Numbers Using Do While Loop?

Sep 15, 2010

i'm trying to achieve is to add two numbers using do while loop. below is the code however result wont show up. i cant seem to determine the error.

<script = "text/javascript">
function myanswer(x,y){
x=parseInt(x);

[code].....

View 1 Replies View Related

Use SetInterval On A Loop?

May 4, 2011

How would you use setInterval so that theres a delay each time javascript runs through a certain loop?

View 10 Replies View Related

For Loop Array

Jan 22, 2008

i am new to programming and have been given the challenge of writing code to request a password, then search through the cP array,until a match is found, then the index number on the cC array which corisponds to the 1st array should show me the customer code.
i have sat here all day and got nowhere, the textbook i have is next to useless and is just confusing me more.

i dont want someone to do it for me but i do need help in getting started as i dont understand how to search for a specific string within the array or how to link the arrays for the correct output. Code:

View 5 Replies View Related

Timeout/while Loop

Apr 6, 2006

I'm trying to decrease my numeric variable in random increments from 0-4 every 5 seconds until this variable reaches 0. Basically it's a countdown, but has a random increment each count. Here's my code:

View 5 Replies View Related

Calling A Value From A Loop

Aug 6, 2006

i am designing a function that will generate a menu to be used across several websites. the code i have developed goes through all of the motion i want it to, except for one quirk: while in the loop, instead of going through the loop and inserting choice1, choice2, et cetera i want it to insert, in this example, news, profile, et cetera.

this is the call to the function: Code:

View 1 Replies View Related

Passing Php Var From Loop To Js?

May 2, 2010

I'm trying to pass a $counter2 value from php loop to javascript, but $counter2 is incremented so I'm passing the highest value of $counter2, which i not what I want to do. Is there a way to combine values with html identifiers and pass them to js?

[URL]

View 2 Replies View Related

Loop Through XML With Script?

Jun 29, 2010

I'm trying to loop through an XML file and display the contents on a HTML page. My problem is the loop is displaying the first set of data and on the 2nd run through says the node is undefined.

Here is a snippet of the XML node I'm looping through [code]...

I think there is an issue with the variable I'm setting in the getElementsByTagName("title")[i] selector, but I'm unsure.

View 11 Replies View Related

While Loop Does Not Work?

Jun 23, 2011

I want to perform a loop while the scroll height of a div is larger than the set height (this will be done for excerpts) however the loop doesn't work (I realize this would be an endless loop). Yet it works when I replace "while" with "if".

function scrollDetect(elemId) {
var elem = document.getElementById(elemId);
while (elem.scrollHeight > elem.clientHeight) {
alert('test!')
}
}
scrollDetect('pmessage');

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved