Loop Working Once But Not A Second Time?

Oct 6, 2009

I have a form on my page that gets checked and verified with a bit of AJAX and then gets sent off if all is good, but I also created a quick little loop to verify that all the fields are still full and completed before sending the info off to the server officially .here is my test page for the loop that i have created.

PHP Code:

<html>
<head>
<script type="text/javascript">

[code]...

Now the loop works great if you test it by clicking on the button once but if you fill in a missing field and click the button ok then it doesnt work again ... how can i get it to work on every click ?

View 3 Replies


ADVERTISEMENT

JQuery :: For Loop Returns Same # Every Time In A Click Function?

Dec 2, 2010

I have a for loop which has a length of 8. It's meant to run through an array of objects and bind a click function to all of them. So the alert should run a range 0-7 but instead it returns 8 no matter which object is being clicked.

for (var j = 0; j < bubbleArray.length; j++) {
$('#icon' + j).bind('click',function() {
var icon = this.id;
this.diam = $(this).width();

[Code].....

View 3 Replies View Related

JQuery :: Loop And Ajax Call - Add 5 To The Variable 'paramdatastart' Each Time The #btn Is Clicked

Apr 8, 2010

I want to add 5 to the variable 'paramdatastart' each time the #btn is clicked. So when I click it first time the 'paramdatastart' will be 5 and next time it will be 10 andso onHow do I do that?

This is the code:

View 3 Replies View Related

JQuery :: While-loop - Working Only Once

Jul 21, 2010

I have while loop, where something is defined via ID, I called it pin_click.

So of course there are a few entries.

And I have the following Code:

Somehow, this Code only works for the first element, I get out of the while loop. The other elements of the while loop ( which have the same Button ) are just doing nothing, even no action in Firebug.

View 6 Replies View Related

JQuery :: Do While Loop Not Working?

May 5, 2010

I'm trying my first bit of jQuery code but am familiar with Java programming. I'm trying to create a function that loads a div with an image in it, which will fade in and then after 4 seconds move onto the next image. I want it to create an infinite loop but it doesn't work.

<script type="text/javascript">
$(document).ready(function ()
{

[code]...

View 4 Replies View Related

Nested For Loop Not Working

Oct 1, 2011

this is code for a conway's game of life. the nested loop on stepGen() doesnt work and i cant figure out what it is. no syntax errors, or anything. i put alert statements to see whats happening. i can provide the rest of the code if necessary.[code]

View 2 Replies View Related

Loop Is Not Working - Clone

Oct 11, 2011

i have this code

<script type="text/javascript">
$(document).ready(function() {
for ($i=0; $i<4; $i++) {
var num = $('.clonedInput').length;

[Code].....

the input id is changed correctly, but valores no. Why ?? Valores is always id="valores1", and must be id="valores1", id="valores2", and so on.

View 2 Replies View Related

For Loop Not Working - How To Make It Work

Jul 17, 2009

Why wont my for loop work it wont alert the var images1....

<script type="text/javascript">
for(i=1;i<6;i++){
images[i] = "no"+i+".jpg";

[code]...

View 2 Replies View Related

Xmlhttp In Loop Not Totally Working

Dec 9, 2004

I have a javascript that is supposed to read a text file (a log from a php script) and it should be shown in a html page. Even more, it should read that txt file again every 10 seconds and update the result every time on the page.

I use xmlhttp for this, after a suggestion from someone on this forum. My script is working well, but only the first time the page is loaded. From then on it becomes unrelieable and I dont know why.

This is the first part: loading a function in the body tag, and a browser version check, I dont think there is any problem in this.

Code:
<body onLoad="showbuffer();">

<script language="JavaScript">
<!--
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
//-->
</script>

This is the second part, a self made looping function that looks up buffer.txt , and writes it on the page.

Code:
<script language="JavaScript">
<!--
function showbuffer() {
xmlhttp.open("GET", "buffer.txt",true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
buffertext=xmlhttp.responseText;
document.body.innerHTML= buffertext;
}
}
xmlhttp.send(null)
return false;
setTimeout('showbuffer()', 10000);
}
//-->
</script>

And this works, if I load my page then it shows exactly the content of buffer.txt . And if a bit later some data is added to the txt file, then it doesnt show up in the xmlhttp page , its still the same content as from the beginning so it didnt update. But there is something really weird about it, if I open up a second browser window and typ in the complete url of the buffer.txt file, and visit that page and look at the new data... then within 10 seconds the new part is added to the xmlhttp page. So the javascript function doesnt work, unless I refresh the page it is supposed to read. I've tried to mimic that, with a php script in crontab that would read buffer.txt through file(); or fopen(); every minute , but that didnt seem to work.

I dont think there is anything wrong with all the xmlhttp part of it, but rather with the way I try to integrate it into a loop. But this setup with setTimeout is the only way I know to make a function repeat itself with a few seconds delay after every step.

So, could anyone please point out how this could be solved ? Maybe another way to loop the xmlhttp part perhaps?

View 1 Replies View Related

Tight Loop Of Code Long For A Long Period Of Time Without Freezing The Page?

May 11, 2011

Is their anyway to have a tight loop of code long for a long period of time without freezing the page? I want to be able to do:

for (i=0;i<9999999999;i++){
//some code
if (i%100==0){
yield();
}
}

View 8 Replies View Related

Loop Function Not Working - How To Make It Work

Jun 8, 2009

I have a pretty simple function set up to pull XML data into my page, but there's a couple things wrong with it. I'm REALLY new to J Script and really trying my best to learn, but for some reason I'm not yet adept at googling the right results :rolleyes:At the very bottom you can see the data from the first XML entry, so it seems the function itself is working fine, but it's not looping coorectly to access all the data.Also, I want to pull it into the "shows" div of the page, but can't figure out how to put it there (seriously, I am very new with JS). The code below is not working, but the live site has it added to the body, which does show the one entry.Here's the XML function, the XML data and the HTML markup:

Shows function -

function loaddates()
{
var xmlData = document.getElementById("tourdates");
var newDates = xmlData.getElementsByTagName("dates");

[code]...

View 4 Replies View Related

Onmouseover Function Inside For Loop Not Working?

Apr 3, 2010

I have a simple HTML page with one DIV element with the id "rotator". Inside that, JavaScript is supposed to create boxes that react to mouseovers.

The weird thing is: The whole script works, but ONLY on the LAST box I create, no matter what I do. I can manually add the mouseover code to any one of these boxes, but it will only take on the last one. I can have JavaScript tell me the mouseover status of each box, and they all tell me they have code assigned correctly - but again only the last one works...

Here's the relevant code (yes, highly abbreviated, but it's the part that fails on me):

var maxBoxes = 10;
function initSite() {
var rotator = document.getElementById("rotator");
rotator.innerHTML = "";

[Code]....

initSite is called in the body onload. All kinds of other animation parts are implemented that work fine, just this mouseover won't work. I have tried re-writing it in multiple different ways, including "xyz.onmouseover = myMouseCode" and then defining the function separately later - still no dice.

So, the code creates 10 boxes (0-9) and 10 boxes that are on top of them to create a form of shadow effect depending on the position of the original boxes. Since the "myDark" boxes are on top of the "myBox" boxes, I apply the onmouseover onto the "myDark" boxes, but it only works on "myDark9" and no other box. They are all created the same way, the mouseover assigned the same way...

View 8 Replies View Related

Function Loop Not Working - Finding The Alternative?

Jun 4, 2010

Here's the code:

for (var i = 1; i < 5; i++)
var pl = eval("player" + i)
var namepl = eval("document.charInput.name" + i + ".value");

[code]....

In the case of the 2nd-4th player, it changes to name2.value, etc.Based on these three inputs, I need to iterate through all four players and make the player object for each of them, as I've done above.

View 5 Replies View Related

Document.formname.elementname.value Not Working In Loop?

Jun 6, 2011

I'm not so good at Javascript, but I tried to write some code to obtain some form values and write those to a query string to use in AJAX.It seems to be working partially, but I don't understand what is going wrong. What happens is that in the for loop the 'document .form_name.form_field_names_array[i].value' part doesn't seem to return a value. It is worse even: the script completely stops executing at that part. When I remove that part from the line in the for loop, it doesn't stop executing, so I guess that's where the problem is?

function doAjaxForm(url, target_element_id, img_url, form_name, form_field_names)
{
// Create the GET query string from the form_fields[code]...

// Rest of the code (the AJAX) is working.

View 3 Replies View Related

Collision Detection Not Working - Causing Infinite Loop

Jan 18, 2010

I cant get collision detection to work. I tried but it always caused an infinite loop.

Heres the code.
<html><!-- main file.--><head>
<title>lightning generator</title>
</head><body>
<canvas id='world' width='500' height='500' style='border: 1px solid black; padding:0;'>
</canvas><script type="text/javascript" src='world.js'></script>
[Code] .....

In the end of world.bolt.cpath,there should be a way to use the local varis X and Y, and world.ground.js's world.ground.level[] to detect it. sorry for the gigantic length.

View 1 Replies View Related

Toggle Show Hide Not Working With <tr><td> <table> Tags In A WHILE Loop

May 6, 2010

Does anyone know why this isn't working? The toggle function works perfectly fine with PHP loops, but when I insert the table td tr tags, it does not hide the loop when the page first loads...It just shows the results in the div which it shouldn't be doing.

Here's what my code looks like...

JS

Code:
<script type="text/javascript">
function toggle(element) {
if (document.getElementById(element).style.display == "none") {

[Code]....

View 3 Replies View Related

JQuery :: Not Working A Second Time?

Oct 5, 2009

I have some simple code:

$(document).ready(
function() {
$('.A1').click(

[code]...

When I click on A1 or A2, the text from the associated files is loadedinto #Info, so that works fine. However, when I click on the A1 or A2class within #Info, nothing happens.I guess I am missing something fundamental here, so it would be veryhelpful if someone could explain how I can get the text that isdisplayed within #Info "clickable" so that it can load the other file.

View 2 Replies View Related

JQuery :: Create 2 Loops, The Inner One I Had Working As Below, Until Tried To Add The Outer Loop Which Iterates Through The Tables?

Apr 8, 2011

Having a tough time integrating the 2. Trying to create 2 loops, the inner one I had working as below, until I tried to add the outer loop which iterates through the tables

<script type="text/javascript">
// <![CDATA[
var i=0;

[code]....

View 7 Replies View Related

JQuery :: 2 Functions Working At The Same Time?

Apr 27, 2011

How can I get 2 functions working at the same time? Here is what I have at the top:

[Code]...

It seams every time i comment out switch.js the innerfade function works then if I comment out jquery.innerfade.js(image change), switch.js (menu)works. But they do not work at the same time so if the images are changeing I cannot hover over the buttons on the menu they act like a graphic, basically not interactive.

View 4 Replies View Related

JQuery :: Ajax Not Working A Second Time

Oct 5, 2009

I have some simple [code]...

When I click on A1 or A2, the text from the associated files is loaded into #Info, so that works fine. However, when I click on the A1 or A2 class within #Info, nothing happens.

View 1 Replies View Related

JQuery :: Document.ready Not Working The 1st Time In IE?

Apr 8, 2010

I use the document.ready function by jquery to trigger some action in an asp page. the problem is that IE has problems the first time the page is loaded. I register the window.resize event for example to do the same actions i do once after first load to keep some alignments correct. these will work in ie but not the initial alignings. I played around with the position of the javascript already and tried everything from having it in the header as well as putting as last element right before </body>.

View 3 Replies View Related

Ajax :: Multiple Requests At Same Time Not Working

Apr 18, 2011

I'm encountering an AJAX problem when I try to execute multiple AJAX requests at the same time. What I want to do is delete a message and display the status (succes or failure) of that in div1, and refresh the messages on the page in div2. This needs (for as far as my knowledge reaches) two AJAX actions from which I both need the responseText.

The problem:
What happens when I execute my script is that the second action (refresh a part of the page) happens before the deletion is executed. The result of this is that when the deletion has been executed, the page is already updated, and the deleted message is still there.

The script
What I now have is:
function doAjax(url, element_id, img_url){
var ajaxObject = createAjaxObject();
ajaxObject.open('GET', url, true);
ajaxObject.onreadystatechange = function(){
if(ajaxObject.readyState==4 && ajaxObject.status==200){
document.getElementById(element_id).innerHTML = ajaxObject.responseText;
delete ajaxObject; .....

View 3 Replies View Related

Textbox Working To Lessen Time In Typing

Nov 10, 2010

I have a question regarding textbox properties. In my textbox username I want to happen is when I input a letter for example is "l" all the letter started in "l" in my field username was appear, so that the user can choose what she want to type to lessen the time in typing like in the google search.

View 6 Replies View Related

JQuery :: Calling The Time And Hiding It On Click (not Working)

Aug 18, 2011

I am trying to show the time and when you click it I want it to go away. But its not working.

<script type="text/javascript">
var date=new Date();
var time=date.getHours();

[Code].....

So I dunno what im doing wrong but when I do this the page is blank.

View 4 Replies View Related

JQuery :: On Page Load Only Working Half The Time?

Feb 7, 2011

I'm helping out a dev at my work who is having a problem.as a function to where it should scollTo (using scrollTo plugin) on page load to the starting "page". I don't think it is a plugin problem though. It only loads correctly about half the time, but if you hit refresh it will work?Can anyone tell me why this is? It's like it doesnt execute it everytime the page loads

View 2 Replies View Related

JQuery :: Attr() Function Not Working In IE7 - Alternatives - Disable Elements In Real Time ?

Jul 28, 2010

Is there any alternative way to disable elements in real time as .attr("disabled",true) or .attr("disabled","disabled") do not work in IE7, only with IE8 or FireFox 3?

View 4 Replies View Related







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