loops

Drop down menu selection with loop

I am creating 2 drop down menus where the first is a start time, e.g. 8:00 am which uses a loop to generate the times, this works fine and the drop down menu has the desired time frames, now i need to create a script which returns as false if the start time is greater than the finish time and i have this: var conting_timefrom=frm_contin...

javascript drop down loop if statement

Possible Duplicate: javascript drop down loop if statement I have created 2 drop down menus, from and to, these include times starting from 8 > 22:00, however on submitting the form it is asking me to select a start time which has already been selected and confirmed by an alert option i have included, has really confused me!! ...

How do I update a sequential attribute with foobar#{n} with n incrementing ?

I want to write basically User.find(:all).each {|u| u.update_attribute("email","nil#{incrementing_number}")} How do I make that #{incrementing_number} incremement per updated attribute. :D ...

Python runs a if-case that it should not!

I have this code: def random_answerlist(self): self.li = [] self.winning_button = random.randint(0, 3) i = 0 while i < 20 and len(self.li) is not 4: if i == self.winning_button: self.li.append(self.flags[self.current_flag][0]) else: new_value = self.random_value() if se...

jQuery: Looping over elements writing their ID attribute to an array?

Hello, I'm trying find a bunch of <label>s in a form of mine based on an array of elements and their id attribute. eg. [ input#country , input#other-country ] would be able to find <label for="country"> , <label for="other-country"> and so on… so far I have this code: var LOCATION = {}; LOCATION.option = form.find('input[name=locati...

While in a Class to Show Posts

i have a class lets call it page and it retrieve somw rows from database (array) and returns them. i want somthing like this: when a class called in a div (<div> $posts->show()</div>) like wordpress and other CMSs i want the div to be looped.i mean like <div>1</div><div>2</div><div>3</div><div>4</div> within the class. ...

for loop in batch file programming

I have not much knowledge in batch file programming. I like to know the working of for loop mainly. For this i think a small sample program will be helpful to me. So i want a simple program to display the first 'n' natural numbers.Any help please... ...

Adding javascript loops into SQL database

What i am trying to achieve is adding the javascript loops and the named variables into an sql database, some of them are already added to an external script so work fine however some which i have named in the SQL script at the bottom still need adding, however as the database won't accept a colon ":" they won't enter it and is returning...

Looping through array and totalling values

Hello, I require a bit of assistance, if someone would be kind enough to help. I have an array with values, which I want to loop through, and if any of the 'user_id values' are the same then to total the 'max_score' value of the duplicate user id's. Array ( [0] => Array ( [user_id] => 2 [max_score]...

In Java, does calling a field accessor in a loop create a new reference on each iteration of the loop?

Say I have a loop like for (Foo aType : bar.getAList()) { if (aType.getBaz().equals(baz)) { return aType; } } bar.getAList() is called on each iteration of the loop. Does the JVM/compiler keep track of the fact that this is the same object, or does it naively call the method and create a reference to the List each time? A...

Python. Showing text from a file in fragments of 20 lines every time ENTER is pressed.

This is the code i have at the moment print "Please input the filename:" n = raw_input() f = open(n,"r") x = 0 for line in f.readlines(): print line x+=1 if x % 20 == 0: break q = raw_input() if q == "": x+= 20 continue Things the program should do: 1) Ask for a filename 2) Read...

Wordpress query_posts adding two "post-entry" divs, one with "post-thumbnail" and one without.

Hi my name is Antony and this is my first question. I'm currently making a worpress theme. And in the loop I want to have two "post-entry" divs one that's small that goes next to my post thumb, and one for without the thumb. I know that I need to do a <div class="post"> <?php if ( has_post_thumbnail()) { ?><div class="post-thumb"> <...

Trying to go to a certain step after its completed one in ruby

Alright. I want it so the following would happen, Heres a sample: puts "what would you like to see?" var = gets.chomp if var == "z" puts "this" elsif var == "d" puts "stack" elsif var == "y" puts "overflow" else puts "I don't understand that." end Currently it works fine up until I want to have the user redefine the 'var'....

Simple check to see if at least one object in a set has a property value of TRUE

I have a set of model objects that have a public IsVisible boolean property. All I need to do is find if at least one of the set has that value set to TRUE. In other words, if I have 10,000 objects but the second one is true, I don't need to spin through the other 9,998. I already have my answer. Now I know I could write my own itera...

Need to loop over an array/list/whatever and *return to caller* each element -but the loop only runs once, of course...

I'm obviously missing something here, as this sound basic enough but yet... I have a collection of objects . I need to use each one of them as parameter in constructor for a new object and return each new object to the caller method, one by one. But -if I loop over the collection obviously the loop only runs once, and only returns the 1...

drawing a simple triangle with a while loop

Back learning after silly life issues derailed me! I decided to switch my learning material and I'm now working through Accelerated C++. Chapter 2, Exercise 5: Write a set of "*" characters so that they form a square, a rectangle, and a triangle. I tried but just couldn't get the triangle down exactly. A quick google found the followi...

Can you loop over a comma separated list of values in a mysql stored procedure

I need to loop over a comma separated list of IDS that were passed into a stored procedure. I have seen people use locate() and substring etc but I haven't seen anything that really makes sense. Thanks! ...

access 2007 a loop to loop through a particular textbox in one form

my problem is as follows I have a properties form which contains a textfield called DateTo(this textfield contains the data type Date) I would like to loop through the DateTo textfield on each of the properties and prints this out in a message box as wasll as a tenantName textfield and a tenantAddress1 field. After this is complete i w...

Scala "<-" for comprehension

Hello guys, I have found that Scala always has a "natural explanation" to anything. Always something like "ohh, but that's just a function being called on this and that object with this and that parameter". In a sense, nothing is really compiler-magic as we know it from other languages. My question is on the <- operator as used in the ...

How to do the following with C?

Basically I want to create an int xfor every time a condition is met so something like... while(CONDITION){ if(int x = 100){ //create a new int //refrence newly created variable } } I then want to run through the loop again but testing newly created variable instead of x. Hopefully this is clear enough! ...