Below is a stripped down example of code I'm using to count links in a list. My intent with the ShowLinkNumber() function was to display the number of the current link. (e.g. click on link 2, and the message "2" pops up; click on link 4, and you see a "4.")
For reasons I can't trace, my function always displays the last number in the list. Why does it do this, and can anyone suggest a way to achieve my goal without adding markup? Code:
I have a problem with a function i created. I want an image to move from a to b and then start from a again. Without parameters this works really fine, but now that I have got more images I use parameters but I have no clue how to call the funtion again.
[Code]...
I tried to replace show(100,flo) with show(100,flo(zahl,r_g)) but then the divs only move from a to b but even will not come back to a again. I think the solution should be pretty simple but i cant figure it out.
take a look at following link and let me know how I can add a loop to my script in order to repeat the animate() function for example for every 30 seconds?[URL].. as you can see the animate function just runs for one time but I would like to repeat it for every 30 seconds. I also would like to add a function to stop the animation when user mouse over on the Logo div.
I've got an array of names, and one ID. I need to run an ajax call using the ID and each lastname, until I get a successful hit on the ajax call. I can't quite figure out how to determine if the function that runs the ajax call has succeeded or not, it always returns false for me... Here's the code for the loop:
Hopefully I 'm missing something silly, but I can't find an easy way to loop all list items in a simple <ol>. I was hoping a for loop as shown below would be enough, however clicking "alert all" in the following example gives me all but the first <li> element. The alertfirst() function finds the first <li> with no problem. There are multiple lists on the page, so getElementsByTagName('li') is probably not the most elegant solution. Btw. my Mozilla crashed when I tried this code, but this is for IE only.
<script type="text/javascript"> function alertfirst() { var ol=document.getElementsByTagName('ol')[0]; alert( ol.firstChild.firstChild.nodeValue ); } function alertall() { var ol=document.getElementsByTagName('ol')[0]; for( var i=ol.firstChild; i=i.nextSibling; i!==null) { alert( i.firstChild.nodeValue ); } } </script> <ol> <li>first</li> <li>second</li> <li>third</li> </ol> <a href="" onclick="alertfirst();return false">alert first</a> <a href="" onclick="alertall();return false">alert all</a>
i am fairly new to javascript and XML. i'm trying to loop through some nodes and drop the output into a series of DIVs using getElementById. here's the code for that: Code:
So, the aim of what I'm doing is to take any amount of text that's in a <textarea>, split it wherever there's a '=====\n' and then call each element of the newly created array back into the <textarea> in a sequential manner.[code]For some reason, my for loop doesn't work. It's only returning the last value in the array and disregarding the previous ones.
I need to loop through all form elements such as text, radios, check boxes and the like and to save their state in a file. does anyone have JS code to do this ?
I am looking for advice on what is "best practice" regarding looping through a form to check its checkboxes and associated data fields.
Here is what I am trying to do (Here is the page I am working on: http://www3.telus.net/thothworks/LinLeastSqPoly4.html). I provide a form for a user to enter up to twenty (M = 20) data pairs. The user need not enter data for all twenty pairs, but the user must indicate that data is present by checking the checkbox beside each valid pair.
If a checkbox is checked, two things happen:
i) a counter, numRows, is incremented to keep track of the total number of valid pairs entered.
ii) the associated two data values (being x and y) are checked to ensure that they are valid numbers and, if so, are entered in an array for use later.
Previously, my forms were small, and I was able to examine each checkbox of a form individually: "if (checkbox1.checked) do action A; if (checkbox2.checked) do action B; if (checkbox3.checked) do action C; etc."
However, now that my form has twenty checkboxes, and may get bigger, I would like to learn how to accomplish this task with a concise loop. Following is my first attempt and it seems to work. If anyone can suggest improvements for this code ....
If got problem with .each looping in jquery. im am trying to make a animation with jQuery. And i want to switch between three quotes of the array. and now it only works for the first quote of the array.
in my code below I am using inlinecontent from thickbox thickbox/) which works but inside the <div id="myOnPageContent"> only shows the first Category Name and doesn't loop through but it is looping outside as it shows a different Category Name at teh top of my inline content
I am practicing looping through a document, finding certain tags and then manipulating them. I have a document with several select tags. 5 of them are very similar showing pirate names. 2 shows pirate ships. The action I would like is if you select a pirate from any select menu, all the other pirate select menus show the same pirate.
This worked as intended until I added the pirate ship select menu to the document. Now for some reason when the script loops through the select tags it is missing some of the pirate ones. The error message I get is that my variable subSelect is null, though it works for some of the loop. I'm not sure why it is dropping it's value.
I have a php page which displays records on the page. I have pagination in these pages which limits the output to a set amount of records per page. As i am designing a display only screen i want it to constantly loop through the links on the page after a set time. My code is:
<script type="text/javascript"> <!-- function delay(){
[code]...
so now it opens screen.php then after 5 secs it goes to screen.php?page=1 (same page) then just keeps refreshing after 5 secs the same page. E.g if i had 10 links on the page i want it to go screen.php?page=2 then page=3 and so on until page=10 then it goes back to the first link i.e page=1 and continuously do this.
I have a list of input1's and inputs2's. The input ones are an accept button and the input2's are a deny button. However, I set up an alert to tell me the name of the input 1's but I am only told the name of the last input1 in my list.
I would like input1.name to show me... something like accept[3]. Where 3 is the uid of the user being accepted or denied. The name works when I look at the source code, but fails when I try to create the alert.
How can I achieve this result?
Code:
So what to do here, thats the question:
- You want to get the data of the button that has been pressed, if such function exists.
- Then use AJAX to send the form data to some file that probably doesnt exist yet.
- Give the PHP a responce, and echot he response to replace the buttons.
I want to use JavaScript so that i can look through the array of these div objects.
var helloDivs = document.getElementByName('hello'); var len = helloDivs.length; .....
So, it works for all the recent version of browsers but not for IE6. There is still about a 10% market share who are still using IE6. What is the workaround for this browser support?
If i were to print the variable len in IE6 says that is 0 and if i print helloDivs, it says it is an object as if helloDivs is a variable that contains an object but not an array of objects.
I have an associative array that I need to loop through, allbills, however, each element in this array requires processing by the user and I need to capture the users actions on the element and then return to the next element in the list but suspend looping until I have the users desired action...
For example,
for(mybill in allbills) { GetWhatToDo(mybill); // gets the information about what user wants to do with the currentBill }
The problem is that the function "GetWhatToDo" doesn't "block" so the loop completes without waiting for the users input from GetWhatToDo...
So, my thought was I need to design things more 'event-driven' and handle things like so:
function handleABill() { mybill=GetNextBill(); GetWhatToDo(mybill); }
A "Next" button inside the popup generated by GetWhatToDo will have an onclick event that calls handleABill again...
The problem is that I can't figure out how to write GetNextBill so that it maintains the state of the loop through 'allbills', especially since 'allbills' is an associative array and I can't keep track of the array index. The only thing I can think of is to initialize a regular array from the associative array and keep track of the index number.
On a page of mine a user might submit data several time, which adds an entry to the history each time (similar as http://www.google.com/trends?q=iPod...o=all&date=all). Yet later the user wants to go back to the previous page in one step. Now is it possible to loop backwards through the history until a different page is reached? Has anybody coded something like this?
This is what i have. It does not correctly add two values when two checkboxes are checked. It should add up to 160 but it adds up to 20 instead! any ideas?
I have a function which is executed whenever someone clicks a checkbox on the page. There are lots of checkboxes on the page. I want the function to be performed on only the unchecked boxes. I've tried this two ways, neither of which has worked. Here are the two methods I've tried.
Where diff is an integer and the values of the checkboxes are all integers. The problem is the function ends up getting run on all checkboxes, even boxes that have been checked.