Search Results

Search found 4036 results on 162 pages for 'nested loops'.

Page 33/162 | < Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >

  • Nested <a> and <span> challenge

    - by PaddyO
    Hi all, Trying in vain to get a nested link working within a nested span. This is a working test page for the code below to explain what I'm trying to do. Any ideas on how to get this working in valid html? I guess it's either a nesting order or style syntax thing but I am at a loss. Any thoughts much appreciated. <div id="greyback"> <ul id="scrollbox"> <li class="listcat">List header</li> <li><a class="menu" href="#freeze">List item 1<span><b>This text has popped up because you have clicked the list item, which has an "a" tag and now has :focus. That "a" tag is the first of two.</b><br><br>What I am trying to do is to set the second "a" tag as a DIFFERENT "embedded" link in this box<span style="color: blue; background-color: yellow;">eg, here<a href="http://www.conservationenterprises.com" target="blank">This is the second (nested) "a" tag in this html nest. It is a link to an external site. Instead of this being an always-visible link, I want it to sit within the yellow box in the first span (click the List item 1 to display).</a></span> </a></span> </li> </a></span> </li> </ul> </div> and the CSS: #scrollbox {margin: 0 auto; margin-top: 1em; margin-bottom: 1em; width:19em; height:auto; max-height: 21em; overflow:auto; border-bottom: 0.1em solid #FFA500; border-top: 0.1em solid #FFA500;} #scrollbox a {float: left; color:#000000; text-decoration:none; width:18em; height: auto; margin-bottom: 0.5em; font-family: Arial, sans-serif; font-size: 0.9em; text-align:left;} #scrollbox a.menu {} #scrollbox a span {display:none; position:absolute; left:0em; top:0;} #scrollbox a span img {float: right; border:0; max-width:7.5em;} #scrollbox a:hover {border: 0; color: #7ebb11; font-size:0.9em;} #scrollbox a:hover span {border: 0; color: #535353;} #scrollbox a span:focus {color: blue;} #scrollbox a:active {border:none; color: #535353; text-decoration: none;} #scrollbox a:focus {border:0em solid #000; outline:0;} #scrollbox a:active span, #scrollbox li a:active span, #scrollbox a:focus span, #scrollbox li a:focus span {display: block; width: 52.5em; min-height: 20em; height: auto; left: 1.5em; top:18em; z-index:10; font-size:0.9em; text-align: left; padding: 1em; padding-bottom: 0em; background-color: #c3FFe3; color: #535353; border: solid #FFA500 0.25em;} #scrollbox li a:active span span, #scrollbox li a:focus span span{display: block; width: auto; height: auto; min-height: 2em; left: 25em; top:10em; z-index:10; font-size:0.9em; text-align: left; padding: 1em; padding-bottom: 0em; background-color: transparent; color: #535353; border: dashed red 1px;} .ul#scrollbox {padding-left: 0.1em;} #scrollbox li {float:left; list-style: none; background: url(blank.png) no-repeat left center; margin-left: 0em; font-family:Arial, sans-serif; font-size: 0.9em;} #scrollbox li.listcat {float: left; text-align:left; width: 18em; margin-left: 0em; margin-top: 0.1em; margin-bottom: 0.3em; padding-top:0.5em; color: green; font-size: 0.9em; font-weight:bold;} Cheers Patrick.

    Read the article

  • My MYSQL & PHP while code is out of memory, when there is only one row

    - by Sam
    Hey all, why is this code throwing an out of memory error, when there is only 1 row in the database.. $request_db = mysql_query("SELECT * FROM requests WHERE haveplayed='0'") or die(mysql_error()); $request = mysql_fetch_array( $request_db ); echo "<table border=\"1\" align=\"center\">"; while ( $request['haveplayed'] == "0" ) { echo "<tr><td>"; echo $request['SongName']; echo "</td><td>"; echo "<tr><td>"; echo $request['Artist']; echo "</td><td>"; echo "<tr><td>"; echo $request['DedicatedTo']; echo "</td><td>"; } echo "</table>"; Thanks.

    Read the article

  • [java] How to get ALL the information from a socket

    - by raven
    Hello, I'll begin this question with the claim that I have read the java networking guide before asking you. I do not understand how to READ the socket and get all the info summed up into a string. the socket might contains more than 1 line [trying to make a chat]. Please do no refer me to any other site unless it clearly states "this exact line does this.." because I failed to understand what this code part does BufferedReader stdIn = new BufferedReader( new InputStreamReader(System.in)); String userInput; while ((userInput = stdIn.readLine()) != null) { out.println(userInput); System.out.println("echo: " + in.readLine()); } Please, I just want to make a loop that will receive information from a socket, get all the content together into one string [I also want it to know where to add another line]. Thanks allot for anyone who helps, I have been trying to get an answer from tuts for hours and just failed to understand!

    Read the article

  • Need help specifying a ending while condition

    - by johnthexiii
    I have written a Python script to download all of the xkcd comic images. The only problem is I can't tell it to stop when it gets to the last one... Here is what I have so far. import re, mechanize from urllib import urlretrieve from BeautifulSoup import BeautifulSoup as bs baseUrl = "http://xkcd.com/1/" #Specify the first comic page br = mechanize.Browser() #Create a browser response = br.open(baseUrl) #Create an initial response x = 1 #Assign an initial file name while (SomeCondition): soup = bs(response.get_data()) #Create an instance of bs that contains the response data img = soup.findAll('img')[1] #Get the online file path of the image localFile = "C:\\Comics\\xkcd\\" + str(x) + ".jpg" #Come up with a local file name urlretrieve(img["src"], localFile) #Download the image file response = br.follow_link(text = "Next >") #Store the response of the next button x += 1 #Increase x by 1 print "All xkcd comics downloaded" #Let the user know the images have been downloaded Initially what I had was something like while br.follow_link(text = "Next >") != br.follow_link(text = ">|"): but by doing this I actually send skip to the last page before the script has a chance to perform the intended purpose.

    Read the article

  • why is there different syntax same outcome?

    - by Lizard
    Why is there different syntax same outcome? For example # Example 1 if($myCondition == true) : #my code here endif; if($myCondition == true) { #my code here } # Example 2 foreach($films as $film) : #my code here endforeach; foreach($films as $film) { #my code here } Also I have been using <?= for ages now and i now understand that is deprecated and I should be using <?php echo Is this the case and why? Its alot more annoying to have to write that out each time. What are your thoughts?

    Read the article

  • [Java]Queue in while loop, cannot modify the value?

    - by javaLearner.java
    This is my code: Iterator it = queue.iterator(); while(it.hasNext()){ random = randNumber(1,2); if(random == 1){ queue.poll(); } else { queue.add("new"); queue.poll(); } } It gives me: Exception in thread "test" java.util.ConcurrentModificationException at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:761) at java.util.LinkedList$ListItr.next(LinkedList.java:696) Edit @Jon Skeet: What I want to do is: I have a queue list in, let say the size is 10, lets say: a,b,c,d ... j Generate a number between 1 and 2. if 1, pull (remove the top element) else if 2 add new element I will stop the loop until I added 3 new elements

    Read the article

  • How to import datarow from one dataset to another?

    - by Disciple
    Hi, I want to copy the row to the new dataset if the previous value in second column isn't the same as the current one (i.e this dataset should have rows with unique values): DataTable tbl = new DataTable(); DataTable tmpTable = ds.Tables[0]; for( var rowIndex = 0; rowIndex < ds.Tables[0].Rows.Count; rowIndex++ ) { object value = null; foreach (DataRow x in tbl.Rows) { if (ds.Tables[0].Rows[rowIndex][1] == x[1]) { value = ds.Tables[0].Rows[rowIndex][1]; break; } } // value already exists if (value == null) { tbl.ImportRow(ds.Tables[0].Rows[rowIndex]); } } How to do this correctly? Maybe one loop instead 2?

    Read the article

  • How do you chain functions dynamically in jQuery?

    - by clarke78
    I want to loop through an object that contains functions which will execute one after another. My most ideal approach would be to have these chain somehow (ie. func2 waits for func1 and func3 waits for func2) but this needs to happen dynamically and the functions will all have different durations. I'm using jQuery so I thought that perhaps "queue()" may help but I haven't worked with it much. A main concern is to not add any scope/callbacks to the functions within the object. I'd rather somehow enclose them within a parent function to execute within the loop in order to create the callback/chaining. Here's an example of what I've got now, but dumbed down. Thanks for any help! var obj = [ {'name':'func1','callback':function(){ alert(1); }}, {'name':'func2','callback':function(){ alert(2); }}, {'name':'func3','callback':function(){ alert(3); }} ]; $.each(obj, function(x, el) { el.callback(); });

    Read the article

  • Calling multiple functions simultaneously with jquery.

    - by clarke78
    I want to loop through an object that contains functions which will execute one after another. My most ideal approach would be to have these chain somehow (ie. func2 waits for func1 and func3 waits for func2) but this needs to happen dynamically and the functions will all have different durations. I'm using jQuery so I thought that perhaps "queue()" may help but I haven't worked with it much. A main concern is to not add any scope/callbacks to the functions within the object. I'd rather somehow enclose them within a parent function to execute within the loop in order to create the callback/chaining. Here's an example of what I've got now, but dumbed down. Thanks for any help! var obj = [ {'name':'func1','callback':function(){ alert(1); }}, {'name':'func2','callback':function(){ alert(2); }}, {'name':'func3','callback':function(){ alert(3); }} ]; $.each(obj, function(x, el) { el.callback(); });

    Read the article

  • Scala Unit type

    - by portoalet
    I use opencsv to parse csv files, and my code is while( (line = reader.readNext()) != null ) { .... } I got a compiler warning saying: comparing values of types Unit and Null using `!=' will always yield true [warn] while( (aLine = reader.readNext()) != null ) { How should I do the while loop?

    Read the article

  • loop prematurely quitting

    - by Nick Gibson
    This loop works fine but prematurely quits at times. I set a piece of code in it so that I can view the random number. It only closes prematurely when the random number is equal to the highest numbered question the user inputs (Example...a user wants 10 questions, if the random number is 10 the program quits.) I have no idea why since i have it set to if(random number <= the number of questions) for ( int loop = 1; loop < loopCount; loop++ ) { aa = r.nextInt ( 10 + 1 ); abc = ( int ) aa; String[] userAnswer = new String[x]; JOptionPane.showMessageDialog ( null, abc ); if ( abc <= x ) { for ( overValue = 1; overValue < forLoop; overValue++ ); { userAnswer[j] = JOptionPane.showInputDialog ( null, "Question " + quesNum + "\n" + questions[abc] + "\n\nA: " + a[abc] + "\nB: " + b[abc] + "\nC: " + c[abc] + "\nD: " + d[abc] ); if ( userAnswer[j].equals ( answers[j] ) ) { JOptionPane.showMessageDialog ( null, "Correct. \nThe Correct Answer is " + answers[abc] ); } else { JOptionPane.showMessageDialog ( null, "Wrong. \n The Correct Answer is " + answers[abc] ); }//else }//for }//if }//for

    Read the article

  • C++ - my loop keeps on adding up to 0

    - by user1756913
    so far here's my code #include <iostream> using namespace std; int main () { int num1 = 0; int num2 = 0; int sum = 0; for(num2 = num1; num1 <= num2; num1 +=2) sum += num1; num1 = num1 / 2 == 0? num1 : num1 + 1; num2 = num2 / 2 == 0? num2 : num2 - 1; cout << "Enter the First Number:" << endl; cin >> num1; cout << "Enter the Second Number:" << endl; cin >> num2; cout << "Total Sum: " << sum << endl; } //end for but the sum keeps on adding up to 0 :/ here's the problem. Create a program that displays the sum of the even numbers between and including two numbers entered by the user. In other words, if the user enters an even number, that number should be included in the sum. For example, if the user enters the integers 2 and 7, the sum is 12 (2 + 4 + 6). If the user enters the integers 2 and 8, the sum is 20 (2 + 4 + 6 + 8 ). Display an error message if the first integer entered by the user is greater than the second integer.

    Read the article

  • What is wrong with this php loop?

    - by Mark R
    I made a loop but it doesn't work. here's what I did: <?php if(is_tree('4')) { ?> <?php $show_after_p = 2; $content = apply_filters('the_content', $post->post_content); if(substr_count($content, '<p>') > $show_after_p) { $contents = explode("</p>", $content); $p_count = 1; foreach($contents as $content) { echo $content; if($p_count == $show_after_p) { ?> YOUR AD CODE GOES HERE < ? } echo "</p>"; $p_count++; } } ?> <?php else : ?> <?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?> <?php endif; } ?> I need to make it work but don't know how. I'm guessing it's a simple syntax error I'm not seeing?

    Read the article

  • PHP: Display comma after each element except the last. Using 'for' statement and no 'implode/explode

    - by Jonathan
    hi, so I have this simple for loop to echo an array: for ($i = 0; $i < count($director); $i++) { echo '<a href="person.php?id='.$director[$i]["id"].'">'.$director[$i]["name"].'</a>'; } The problem here is that when more than one element is in the array then I get everything echoed without any space between. I want to separate each element with a comma except the last one. I cant use 'implode' so I'm looking for another solution... Anyone?

    Read the article

  • How to output multiple rows from an SQL query using the mysqli object

    - by Jonathan
    Assuming that the mysqli object is already instantiatied (and connected) with the global variable $mysql, here is the code I am trying to work with. class Listing { private $mysql; function getListingInfo($l_id = "", $category = "", $subcategory = "", $username = "", $status = "active") { $condition = "`status` = '$status'"; if (!empty($l_id)) $condition .= "AND `L_ID` = '$l_id'"; if (!empty($category)) $condition .= "AND `category` = '$category'"; if (!empty($subcategory)) $condition .= "AND `subcategory` = '$subcategory'"; if (!empty($username)) $condition .= "AND `username` = '$username'"; $result = $this->mysql->query("SELECT * FROM listing WHERE $condition") or die('Error fetching values'); $this->listing = $result->fetch_array() or die('could not create object'); foreach ($this->listing as $key => $value) : $info[$key] = stripslashes(html_entity_decode($value)); endforeach; return $info; } } there are several hundred listings in the db and when I call $result-fetch_array() it places in an array the first row in the db. however when I try to call the object, I can't seem to access more than the first row. for instance: $listing_row = new Listing; while ($listing = $listing_row-getListingInfo()) { echo $listing[0]; } this outputs an infinite loop of the same row in the db. Why does it not advance to the next row? if I move the code: $this->listing = $result->fetch_array() or die('could not create object'); foreach ($this->listing as $key => $value) : $info[$key] = stripslashes(html_entity_decode($value)); endforeach; if I move this outside the class, it works exactly as expected outputting a row at a time while looping through the while statement. Is there a way to write this so that I can keep the fetch_array() call in the class and still loop through the records?

    Read the article

  • form_for called in a loop overloads IDs and associates fields and labels incorrectly

    - by Katy Levinson
    Rails likes giving all of my fields the same IDs when they are generated in a loop, and this causes trouble. <% current_user.subscriptions.each do |s| %> <div class="subscription_listing"> <%= link_to_function s.product.name, "toggle_delay(this)"%> in <%= s.calc_time_to_next_arrival %> days. <div class="modify_subscription"> <%= form_for s, :url => change_subscription_path(s) do |f| %> <%= label_tag(:q, "Days to delay:") %> <%= text_field_tag(:query) %> <%= check_box_tag(:always) %> <%= label_tag(:always, "Apply delay to all future orders") %> <%= submit_tag("Change") %> <% end %> <%= link_to 'Destroy', s, :confirm => 'Are you sure?', :method => :delete %> </div> </div> <% end %> Produces <div class="subscription_listing"> <a href="#" onclick="toggle_delay(this); return false;">Pasta</a> in 57 days. <div class="modify_subscription"> <form accept-charset="UTF-8" action="/subscriptions/7/change" class="edit_subscription" id="edit_subscription_7" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="_method" type="hidden" value="put" /><input name="authenticity_token" type="hidden" value="s5LJffuzmbEMkSrez8b3KLVmDWN/PGmDryXhp25+qc4=" /></div> <label for="q">Days to delay:</label> <input id="query" name="query" type="text" /> <input id="always" name="always" type="checkbox" value="1" /> <label for="always">Apply delay to all future orders</label> <input name="commit" type="submit" value="Change" /> </form> <a href="/subscriptions/7" data-confirm="Are you sure?" data-method="delete" rel="nofollow">Destroy</a> </div> </div> <div class="subscription_listing"> <a href="#" onclick="toggle_delay(this); return false;">Gummy Bears</a> in 57 days. <div class="modify_subscription"> <form accept-charset="UTF-8" action="/subscriptions/8/change" class="edit_subscription" id="edit_subscription_8" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="_method" type="hidden" value="put" /><input name="authenticity_token" type="hidden" value="s5LJffuzmbEMkSrez8b3KLVmDWN/PGmDryXhp25+qc4=" /></div> <label for="q">Days to delay:</label> <input id="query" name="query" type="text" /> <input id="always" name="always" type="checkbox" value="1" /> <label for="always">Apply delay to all future orders</label> <input name="commit" type="submit" value="Change" /> </form> <a href="/subscriptions/8" data-confirm="Are you sure?" data-method="delete" rel="nofollow">Destroy</a> </div> </div> And that's a problem because now no matter which "Apply delay to all future orders" I select it always very helpfully checks the first box for me. How can I override the ID without doing something ugly and un-rails-like?

    Read the article

  • Moving x,y position of all array objects every frame in actionscript 3?

    - by Dylan Gallardo
    I have my code setup so that I have an movieclip in my library a class called "block" being duplicated multiple times and added into an array like this: function makeblock(e:Event){ newblock=new block; newblock.x=10; newblock.y=10; addChild(newblock); myarray[counter] = newblock; //adds a newblock object into array counter += 1; } Then I have a loop with a currently primitive way of handling my problem: stage.addEventListener(Event.ENTER_FRAME, gameloop); function gameloop(evt:Event):void { if (moveright==true){ myarray[0].x += 5; myarray[1].x += 5; myarray[2].x += 5 -(and so on)- My question is how can I change x,y values every frame for new objects duplicated into the array, along with the previous ones that were added. Of course with a more elegant way than writing it out myself... array[0].x += 5, array[1], array[2], array[3] etc. Ideally I would like this to go up to 500 or more array objects for one array so obviously I don't want to be writing it out individually haha, I also need it to be consistent with performance so using a for loop or something to loop through the whole array and move each x += 5 wouldn't work would it? Anyway, if anyone has any ideas that'd be great!

    Read the article

  • Loop on enumeration values

    - by Rachel
    How awful is it - or is it perfectly acceptable - to index a loop on an enumeration? I have an enumeration defined. The values of the literals are default values. The assigned values do not have any significance, will not have any significance, and the values of any literals added in the future will also not have any significance. It's just defined to limit the allowed values and to make things easier to follow. Therefore the values will always start at 0 and increase by 1. Can I set up a loop like so: enum MyEnum { value1, value2, value3, maxValue } for(MyEnum i = value1; i < maxValue; i = static_cast<MyEnum>(i+1)){}

    Read the article

  • VB.NET 2008 Application crashing during Do Loop

    - by RedHaze
    I am writing an application to compare each item on listbox1 to all items on listbox2. If the item is found, then remove it from both lists. The goal is to only have the items that were not found remain on both lists. The problem is, the application just hangs and I never get any results. I looked at my code several times and I cannot figure out what's going on (programming noob I know...). Can anybody help me with this? Code Snippet: Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim a As String Dim b As String Dim y As String For i As Integer = 0 To ListBox1.Items.Count - 1 a = ListBox1.Items(i) y = 1 Do While y = 1 For x As Integer = 0 To ListBox2.Items.Count - 1 b = ListBox2.Items(x) Dim res As Int16 = String.Compare(a, b) If res = 0 Then y = 0 ListBox2.Items.Remove(i) ListBox2.Items.Remove(x) ElseIf x = ListBox1.Items.Count Then Exit Do End If Next Loop Next End Sub

    Read the article

  • VB looping complication

    - by user1819469
    I have to come up with a program that shifts names in a text box a random amount of times. I have gotten everything up to the point where the names shifts a random amount of times. It only shifts its once, but my messagebox appears through the code as many times as the names should be shifting once i click ok. Does anyone know why the loop is not working for the name shifts. I was thinking maybe the messagebox needs to control the loop, but I have searched endlessly and cannot find how that would be done. Any suggestions or referrals to other sites would be nice thanks. My code is below. Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim RandomNumber As Integer Dim min, max As Integer Dim temp, temp2, temp3, temp4, temp5, temp6 As String Dim i As Integer min = 3 max = 11 Randomize() RandomNumber = Int((max - min + 1) * Rnd() + min) temp = n1.Text temp2 = n2.Text temp3 = n3.Text temp4 = n4.Text temp5 = n5.Text temp6 = n6.Text For i = 0 To RandomNumber - 1 n1.Text = temp6 n2.Text = temp n3.Text = temp2 n4.Text = temp3 n5.Text = temp4 n6.Text = temp5 MessageBox.Show("Shift " & i & " of " & RandomNumber & " complete") Next End Sub End Class

    Read the article

  • Help with simple javascript loop

    - by Gabriel
    Hello, I have a simple javascript that I'd like to loop for multiple elements. Here's my code: <script type='text/javascript'> for(i = 1; i < 100; i++) { $('#link'+i).click(function() { $('#container').removeClass(); $('#container').addClass('templateid'+i); }); } </script> What I'd like to achieve is the same addClass function for multiple id's (e.g. link2, link3, link4), with the corresponding class (e.g. template2, template3, template4). Any help would be hugely appreciated! For reference, an individual call like this one, does work, so I don't see why the loop above doesn't function the same: <script type='text/javascript'> $('#link2').click(function() { $('#container').removeClass(); $('#container').addClass('templateid2'); }); </script>

    Read the article

  • JQuery: loop through elements with more than one css class name that share only the first class name

    - by omaether
    Hello, I'm trying to use JQuery to loop through several div's with more than one class name, that all have the same first css class name and each one has a different second class name, e.g. <div class="maintext blue"> </div> <div class="maintext purple"> </div> <div class="maintext chartreuse"> </div> <div class="maintext puce"> </div> <div class="maintext lime"> </div> In JQuery I have tried $(".mainText").each(function (i) $(".mainText.*").each(function (i) $(".mainText" *).each(function (i) $(".mainText .*").each(function (i) But it will not select any of the divs with class="mainText ..." thanks for considering the question.

    Read the article

  • Loop each x elements

    - by Cimm
    What's the beste way to show a list with 20 images in rows of 5? Or, in other words, how do I clean up this ugly snippet? <div class="row"> <% @images.each_with_index do |image, index| %> <%= image_tag image.url %> <% if index != 0 && index % 5 == 0 %> </div><div class="row"> <% end %> <% end %> </div>

    Read the article

< Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >