loops

JQUERY - Find all Elements with Class="X" and then POST all those elements to the server to INS into the DB

Given a large text block from a WYSIWYG like: Lorem ipsum dolor sit amet, <span class="X" id="12">consectetur adipiscing elit</span>. Donec interdum, neque at posuere scelerisque, justo tortor tempus diam, eu hendrerit libero velit sed magna. Morbi laoreet <span class="X" id="13">tincidunt quam in facilisis.</span> Cras lacinia turpis v...

Getting an error on my foreach loop

Here is the code: <?php //Starting session session_start(); //Includes mass includes containing all the files needed to execute the full script //Also shows homepage elements without customs require_once ('includes/mass.php'); $username = $_SESSION['username']; if (isset($username)) { //Query database for the users networths ...

Java do while, while

Hello, what behaviour can I expect when I run this code: do while(testA) { // do stuff } while(testB); Will it behave like: do { while(testA) { // do stuff } } while(testB); Or: if(testA) { do { // do stuff } while(testA && testB); } Or something totally unexpected? I ask this question...

jQuery each doesn't have a callback-possibility?

Hello I have a loop created with each, check this example: $('.foo').each(function(i){ //do stuff }); Is there any possibility to run a functions when this loop has ended? Couldn't find it on docs or Google. I can make it work without this kind of solution, but it's always good to search for and use the simpliest methods. Martti ...

Looping though a while statement

Hi I have a sequence of mysql query result resources stored in a array. E.G array([0] => resource [1] => resource ...ect); This code retrieves the first resource in the array: $third_count = "0"; while ($user_result = mysql_fetch_array($user[$third_count])) { print_r($user_result); } $third_count = $third_count +1; I'm just stuck t...

conditional while loop in php?

I'm pretty sure there's an obvious answer for this-- hoping someone can help me-- I need to do a PHP while loop, but only if a variable is true. And I can't really put the while loop in an "if" statement, which seems like the obvious thing to do, since the code block is huge and it would be ugly and confusing. Do I need to break out th...

jQuery - how to repeat a function within itself to include nested files

I'm not sure what to call this question, since it involves a variety of things, but we'll start with the first issue... I've been trying to write a simple to use jQuery for includes (similar to php or ssi) on static html sites. Whenever it finds div.jqinclude it gets attr('title') (which is my external html file), then uses load() to i...

JQUERY/JSON, given a variable list of items, how to post to the server

I have a .each() that is running a loop to find the following below.. Given the following which builds during the .each loop id - desc 313 - blah blah 213 - blah blah 313 - blah blah 323 - blah blah How can I form this data in JQUERY to be posted to the server (coldfusion) ...

Windows Command Line

Does anyone know how to break out of a for loop when it's typed directly into the windows command-line? I know you can use gotos and labels to break out of it when it's in a batch file, but I can't find anything about breaking out of one on the command line. Here's a simple example: C:> for /l %i in (1,0,1) do @ping -n 1 google.com ||...

How to create a JSON Object {"x":"16","y":"XXXX"}.... in JQUERY?

Given the following: What I would like to happen: 1. Find all Span TAGS with class="location" 2. Loop through these and create a JSON string to post to the server // Determine how many there are var postText = $("#container").html(); var numFound = $("span.location").length; var countVar = 0; //Loop through all the Locations $( "span....

PHP Find Coordinates between two points

Hi all, simple question here. Lets say I have two points: point 1 x = 0 y = 0 point 2 x = 10 y = 10 How would i find out all the coordinates inbetween that programmatically, assuming there is a strait line between two points... so the above example would return: 0,0 1,1 2,2 3,3 ... 8,8 9,9 10,10 Thanks :) ...

Coding the R-ight way - avoiding the for loop

I am going through one of my .R files and by cleaning it up a little bit I am trying to get more familiar with writing the code the r-ight way. As a beginner, one of my favorite starting points is to get rid of the for() loops and try to transform the expression into a functional programming form. So here is the scenario: I am assemblin...

jQuery fadeIn/fadeOut loop problem

Hi. I'm trying to do a sequential animation with a loop....but i can't accomplish it in a smooth way (some "lag" problems). jQuery var i = 0; var b = 0; var fades = function(){$(".caja").stop(0).each(function(){ $(this).delay(i * 500).fadeIn('slow', function(){ $(this).delay(5000).fadeOut('slow', function(){ $(".cajar").delay...

Blinking an item. (Jquery FadeIn FadeOut ?)

I have two divs that I want to make blink at the same time until the user hovers the mouse on one of them. var shouldiblink = '1'; function mrBlinko(divid){ while (shouldiblink =='1') { $("#"+divid).fadeIn(100).fadeOut(300); } $(document).ready(function(){ mrBlinko("mydiv1"); mrBlinko("mydiv2"); } The I'll have an hover event th...

Ruby: How to loop through an object that may or may not be an array?

I have an each method that is run on some user-submitted data. Sometimes it will be an array, other times it won't be. Example submission: <numbers> <number>12345</number> </numbers> Another example: <numbers> <number>12345</number> <number>09876</number> </numbers> I have been trying to do an each do on that, but whe...

How do I apply the for-each loop to every character in a String in Java?

So I want to iterate for each character in a string. So I thought: for (char c : "xyz") but I get a compiler error: StackCharTester.java:20: foreach not applicable to expression type How can I do this? ...

How to parse a string (by a "new" markup) with R ?

Hi all, I want to use R to do string parsing that (I think) is like a simplistic HTML parsing. For example, let's say we have the following two variables: Seq <- "GCCTCGATAGCTCAGTTGGGAGAGCGTACGACTGAAGATCGTAAGGtCACCAGTTCGATCCTGGTTCGGGGCA" Str <- ">>>>>>>..>>>>........<<<<.>>>>>.......<<<<<.....>>>>>.......<<<<<<<<<<<<." Say that I wa...

AS3 : RegExp exec method in loop problem

Hi everyone, I need some help about RegExp in AS3. I have a simple pattern : patternYouTube = new RegExp ( "v(?:\/|=)([A-Z0-9_-]+)", "gi" ); This pattern is looking for the youTube id video. For example : var tmpUrl : String; var result : Object; var toto : Array = new Array(); toto = ["http://www.youtube.com/v/J-vCxmjCm-8&am...

How to organize infinite while loop in SQL Server ?

I want to use infinite WHILE loop in SQL Server 2005 and use BREAK keyword to exit from it on certain condition. while true does not work, so I have to use while 1=1. Is there a better way to organize infinite loop ? I know that I can use goto, but while 1=1 begin .. end looks better structurally. ...

Bash: for loop, copy, backup

Hey, not 100% sure what this error means. % for f in "*" ; do cp $f ../backup/backup$f ; done cp: ../backup/backup* not found The purpose is to copy all the files into a folder into a backup folder and rename the files to backup. ...