Search Results

Search found 2536 results on 102 pages for 'nested'.

Page 5/102 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Is nested synchronized block necessary?

    - by Dan
    I am writing a multithreaded program and I have a method that has a nested synchronized blocks and I was wondering if I need the inner sync or if just the outer sync is good enough. public class Tester { private BlockingQueue<Ticket> q = new LinkedBlockingQueue<>(); private ArrayList<Long> list = new ArrayList<>(); public void acceptTicket(Ticket p) { try { synchronized (q) { q.put(p); synchronized (list) { if (list.size() < 5) { list.add(p.getSize()); } else { list.remove(0); list.add(p.getSize()); } } } } catch (InterruptedException ex) { Logger.getLogger(Consumer.class.getName()).log(Level.SEVERE, null, ex); } } } EDIT: This isn't a complete class as I am still working on it. But essentially I am trying to emulate a ticket machine. The ticket machine maintains a list of tickets in the BlockingQueue q. Whenever a client adds a ticket to the machine, the machine also keeps track of the price of the last 5 tickets (ArrayList list)

    Read the article

  • Nested IF statements in Excel [Over the 7 allowed limit]

    - by Alks
    hey guys, i am trying to create a spreadsheet which automagically gives a grade to a student based on their marks they got. I've apparently hit excels nested IF statement limit which is 7. here's my if statement: =IF(O5>0.895,"A+",IF(O5>0.845,"A",IF(O5>0.795,"A-",IF(O5>0.745,"B+",IF(O5>0.695,"B",IF(O5>0.645,"B-",IF(O5>0.595,"C+",IF(O5>0.545,"C","D")))))))) I was reading online that I could create a VBA script and assign it that, but I dont know anything about VBA....so if someone could help me write a VBA for this, would be awesome. Its still mising the C- grade and anything lower should be awarded a D mark. This is the grading scheme I am trying to create...: A+ 89.500 - 100.000 Pass with Distinction A 84.500 - 89.490 Pass with Distinction A- 79.500 - 84.490 Pass with Distinction B+ 74.500 - 79.490 Pass with Merit B 69.500 - 74.490 Pass with Merit B- 64.500 - 69.490 Pass with Merit C+ 59.500 - 64.490 Pass C 54.500 - 59.490 Pass C- 49.500 - 54.490 Pass D 0.000 - 49.490 Specified Fail I wouldn't mind going down the VBA route, however my understanding of VB language is absolutely minimal (don't like it)...if this gets too tedious, I was thinking to create a small php/mysql application instead. Cheers :)

    Read the article

  • How to render all records from a nested set into a real html tree

    - by Christoph Schiessl
    I'm using the awesome_nested_set plugin in my Rails project. I have two models that look like this (simplified): class Customer < ActiveRecord::Base has_many :categories end class Category < ActiveRecord::Base belongs_to :customer # Columns in the categories table: lft, rgt and parent_id acts_as_nested_set :scope => :customer_id validates_presence_of :name # Further validations... end The tree in the database is constructed as expected. All the values of parent_id, lft and rgt are correct. The tree has multiple root nodes (which is of course allowed in awesome_nested_set). Now, I want to render all categories of a given customer in a correctly sorted tree like structure: for example nested <ul> tags. This wouldn't be too difficult but I need it to be efficient (the less sql queries the better). Update: Figured out that it is possible to calculate the number of children for any given Node in the tree without further SQL queries: number_of_children = (node.rgt - node.lft - 1)/2. This doesn't solve the problem but it may prove to be helpful.

    Read the article

  • Sorting nested set by name while keep depth integrity

    - by wb
    I'm using the nested set model that'll later be used to build a sitemap for my web site. This is my table structure. create table departments ( id int identity(0, 1) primary key , lft int , rgt int , name nvarchar(60) ); insert into departments (lft, rgt, name) values (1, 10, 'departments'); insert into departments (lft, rgt, name) values (2, 3, 'd'); insert into departments (lft, rgt, name) values (4, 9, 'a'); insert into departments (lft, rgt, name) values (5, 6, 'b'); insert into departments (lft, rgt, name) values (7, 8, 'c'); How can I sort by depth as well as name? I can do select replicate('----', count(parent.name) - 1) + ' ' + node.name , count(parent.name) - 1 as depth , node.lft from departments node , departments parent where node.lft between parent.lft and parent.rgt group by node.name, node.lft order by depth asc, node.name asc; However, that does not match children with their parent for some reason. department lft rgt --------------------------- departments 0 1 ---- a 1 4 ---- d 1 2 -------- b 2 5 -------- c 2 7 As you can see, department 'd' has department 'a's children! Thank you.

    Read the article

  • Use jQuery's dataTable plugin with a nested Ajax call

    - by mrr0ng
    I am trying to use a nested ajax call to populate a table, and once the table is built, use jQuery's dataTable plugin to pretty it up. The problem I am running into is an order of operations question. When do I call the dataTable function so that I can be assured that the table is built AFTER the values are populated? When I try the following code, the dataTable is created before the rows are built. <script type="text/javascript"> $(document).ready(function() { $.ajax({ url:"http://totalrockregistration.com/feeds/bands.php", dataType:"jsonp", success: function(jsonData){ $.each(jsonData.bands, function(i,bands){ if (bands.barID == "<?php echo $_GET["barID"]; ?>"){ var songIdFromBandJson = bands.song; var bandNameFromJson = bands.name; var bandScoreFromJson = bands.score; $.ajax({ url:"http://totalrockregistration.com/feeds/songs.php", dataType:"jsonp", success: function(songsJsonData){ $.each(songsJsonData.songs, function(i,songs){ if (songIdFromBandJson == songs.id){ var songName=(songs.name); $("#leaderBoardTable tbody").append("<tr><td>"+bandNameFromJson+"</td><td>"+bandScoreFromJson+"</td><td>"+songName+"</td></tr>"); } }); } }); } }); makeLeaderTable(); }, }); function makeLeaderTable(){ $('#leaderBoardTable').dataTable({ "aaSorting": [[ 1, "desc" ]], "iDisplayLength": 50 }); } }); </script>

    Read the article

  • Rails Nested Attributes Doesn't Insert ID Correctly

    - by MunkiPhD
    I'm attempting to edit a model's nested attributes, much as outline here, replicated here: <%= form_for @person do |person_form| %> <%= person_form.text_field :name %> <% for address in @person.addresses %> <%= person_form.fields_for address, :index => address do |address_form|%> <%= address_form.text_field :city %> <% end %> <% end %> <% end %> In my code, I have the following: <%= form_for(@meal) do |f| %> <!-- some other stuff that's irrelevant... --> <% for subitem in @meal.meal_line_items %> <%= f.fields_for subitem, :index => subitem do |line_item_form| %> <%= line_item_form.label :servings %><br/> <%= line_item_form.text_field :servings %><br/> <%= line_item_form.label :food_id %><br/> <%= line_item_form.text_field :food_id %><br/> <% end %> <% end %> <%= f.submit %> <% end %> This works great, except, when I look at the HTML, it's creating the inputs that look like the following, failing to input the correct id and instead placing the memory representation(?) of the model: <input type="text" value="2" size="30" name="meal[meal_line_item][#<MealLineItem:0x00000005c5d618>][servings]" id="meal_meal_line_item_#<MealLineItem:0x00000005c5d618>_servings">

    Read the article

  • Rails: radio button selection for nested forms objects

    - by satynos
    I have the following form for photo_album which uses the nested forms feature of the Rails in saving the photos while updating the photo_album. And having trouble with the selection of radio button value. I want only one of the photos be able to select as the album cover, but due to the way rails produces form element ids and names, I am able to select all of the photos as album covers. Is there any workaround? <% form_for @photo_album do |f| %> <%= f.error_messages %> <% @photo_album.photos.each do |photo| %> <% f.fields_for :photos, photo do |photo_fields| %> <p> <%= image_tag url_for_image_column(photo, "data", :thumb) %> </p> <p> <%= photo_fields.label :title %> <%= photo_fields.text_field :title %> </p> <p> <%= photo_fields.label :body %> <%= photo_fields.text_area :body %> </p> <p> <%= photo_fields.radio_button :cover, "1" %> <%= photo_fields.label :cover, 'Album Cover', :class => 'option' %> <%= photo_fields.check_box :_delete %> <%= photo_fields.label :_delete, 'Delete', :class => 'option' %> </p> <% end %> <% end %> <p> <%= f.submit @photo_album.new_record? ? 'Create' : 'Update' %> </p> <% end %> And following is the html produced by rails (which is part of the problem) for radio buttons: <p> <input type="radio" value="1" name="photo_album[photos_attributes][0][cover]" id="photo_album_photos_attributes_0_cover_1"/> <label for="photo_album_photos_attributes_0_cover" class="option">Album Cover</label> <input type="hidden" value="0" name="photo_album[photos_attributes][0][_delete]"/><input type="checkbox" value="1" name="photo_album[photos_attributes][0][_delete]" id="photo_album_photos_attributes_0__delete"/> <label for="photo_album_photos_attributes_0__delete" class="option">Delete</label> </p>

    Read the article

  • "Can't mass-assign protected attributes" with nested protected models

    - by JohnnyFive
    I'm having a hell of a time trying to get this nested model working. I've tried all manner of pluralization/singular, removing the attr_accessible altogether, and who knows what else. restaurant.rb: # == RESTAURANT MODEL # # Table name: restaurants # # id :integer not null, primary key # name :string(255) # created_at :datetime not null # updated_at :datetime not null # class Restaurant < ActiveRecord::Base attr_accessible :name, :job_attributes has_many :jobs has_many :users, :through => :jobs has_many :positions accepts_nested_attributes_for :jobs, :allow_destroy => true validates :name, presence: true end job.rb: # == JOB MODEL # # Table name: jobs # # id :integer not null, primary key # restaurant_id :integer # shortname :string(255) # user_id :integer # created_at :datetime not null # updated_at :datetime not null # class Job < ActiveRecord::Base attr_accessible :restaurant_id, :shortname, :user_id belongs_to :user belongs_to :restaurant has_many :shifts validates :name, presence: false end restaurants_controller.rb: class RestaurantsController < ApplicationController before_filter :logged_in, only: [:new_restaurant] def new @restaurant = Restaurant.new @user = current_user end def create @restaurant = Restaurant.new(params[:restaurant]) if @restaurant.save flash[:success] = "Restaurant created." redirect_to welcome_path end end end new.html.erb: <% provide(:title, 'Restaurant') %> <%= form_for @restaurant do |f| %> <%= render 'shared/error_messages' %> <%= f.label "Restaurant Name" %> <%= f.text_field :name %> <%= f.fields_for :job do |child_f| %> <%= child_f.label "Nickname" %> <%= child_f.text_field :shortname %> <% end %> <%= f.submit "Done", class: "btn btn-large btn-primary" %> <% end %> Output Parameters: {"utf8"=>"?", "authenticity_token"=>"DjYvwkJeUhO06ds7bqshHsctS1M/Dth08rLlP2yQ7O0=", "restaurant"=>{"name"=>"The Pink Door", "job"=>{"shortname"=>"PD"}}, "commit"=>"Done"} The error i'm receiving is: ActiveModel::MassAssignmentSecurity::Error in RestaurantsController#create Cant mass-assign protected attributes: job Rails.root: /home/johnnyfive/Dropbox/Projects/sa Application Trace | Framework Trace | Full Trace app/controllers/restaurants_controller.rb:11:in `new' app/controllers/restaurants_controller.rb:11:in `create' Anyone have ANY clue how to get this to work? Thanks!

    Read the article

  • Nested attributes form for model which belongs_to few models

    - by ExiRe
    I have few models - User, Teacher and TeacherLeader. class User < ActiveRecord::Base attr_accessible ..., :teacher_attributes has_one :teacher has_one :teacher_leader accepts_nested_attributes_for :teacher_leader end class Teacher < ActiveRecord::Base belongs_to :user has_one :teacher_leader end class TeacherLeader < ActiveRecord::Base belongs_to :user belongs_to :teacher end I would like to fill TeacherLeader via nested attributes. So, i do such things in controller: class TeacherLeadersController < ApplicationController ... def new @user = User.new @teacher_leader = @user.build_teacher_leader @teachers_collection = Teacher.all.collect do |t| [ "#{t.teacher_last_name} #{t.teacher_first_name} #{t.teacher_middle_name}", t.id ] end @choosen_teacher = @teachers_collection.first.last unless @teachers_collection.empty? end end And also have such view (new.html.erb): <%= form_for @user, :url => teacher_leaders_url, :html => {:class => "form-horizontal"} do |f| %> <%= field_set_tag do %> <% f.fields_for :teacher_leader do |tl| %> <div class="control-group"> <%= tl.label :teacher_id, "Teacher names", :class => "control-label" %> <div class="controls"> <%= select_tag( :teacher_id, options_for_select( @teachers_collection, @choosen_teacher )) %> </div> </div> <% end %> <div class="control-group"> <%= f.label :user_login, "Login", :class => "control-label" %> <div class="controls"> <%= f.text_field :user_login, :placeholder => @everpresent_field_placeholder %> </div> </div> <div class="control-group"> <%= f.label :password, "Pass", :class => "control-label" %> <div class="controls"> <%= f.text_field :password, :placeholder => @everpresent_field_placeholder %> </div> </div> <% end %> <%= f.submit "Create", :class => "btn btn-large btn-success" %> <% end %> Problem is that select form here does NOT appear. Why? Do i do something wrong?

    Read the article

  • Nested WHILE loops not acting as expected - Javascript / Google Apps Script

    - by dthor
    I've got a function that isn't acting as intended. Before I continue, I'd like preface this with the fact that I normally program in Mathematica and have been tasked with porting over a Mathematica function (that I wrote) to JavaScript so that it can be used in a Google Docs spreadsheet. I have about 3 hours of JavaScript experience... The entire (small) project is calculating the Gross Die per Wafer, given a wafer and die size (among other inputs). The part that isn't working is where I check to see if any corner of the die is outside of the effective radius, Reff. The function takes a list of X and Y coordinates which, when combined, create the individual XY coord of the center of the die. That is then put into a separate function "maxDistance" that calculates the distance of each of the 4 corners and returns the max. This max value is checked against Reff. If the max is inside the radius, 1 is added to the die count. // Take a list of X and Y values and calculate the Gross Die per Wafer function CoordsToGDW(Reff,xSize,ySize,xCoords,yCoords) { // Initialize Variables var count = 0; // Nested loops create all the x,y coords of the die centers for (var i = 0; i < xCoords.length; i++) { for (var j = 0; j < yCoords.length, j++) { // Add 1 to the die count if the distance is within the effective radius if (maxDistance(xCoords[i],yCoords[j],xSize,ySize) <= Reff) {count = count + 1} } } return count; } Here are some examples of what I'm getting: xArray={-52.25, -42.75, -33.25, -23.75, -14.25, -4.75, 4.75, 14.25, 23.75, 33.25, 42.75, 52.25, 61.75} yArray={-52.5, -45.5, -38.5, -31.5, -24.5, -17.5, -10.5, -3.5, 3.5, 10.5, 17.5, 24.5, 31.5, 38.5, 45.5, 52.5, 59.5} CoordsToGDW(45,9.5,7.0,xArray,yArray) returns: 49 (should be 72) xArray={-36, -28, -20, -12, -4, 4, 12, 20, 28, 36, 44} yArray={-39, -33, -27, -21, -15, -9, -3, 3, 9, 15, 21, 27, 33, 39, 45} CoordsToGDW(32.5,8,6,xArray,yArray) returns: 39 (should be 48) I know that maxDistance() is returning the correct values. So, where's my simple mistake? Also, please forgive me writing some things in Mathematica notation... Edit #1: A little bit of formatting. Edit #2: Per showi, I've changed WHILE loops to FOR loops and replaced <= with <. Still not the right answer. It did clean things up a bit though... Edit #3: What I'm essentially trying to do is take [a,b] and [a,b,c] and return [[a,a],[a,b],[a,c],[b,a],[b,b],[b,c]]

    Read the article

  • Improved way to build nested array of unique values in javascript

    - by dualmon
    The setup: I have a nested html table structure that displays hierarchical data, and the individual rows can be hidden or shown by the user. Each row has a dom id that is comprised of the level number plus the primary key for the record type on that level. I have to have both, because each level is from a different database table, so the primary key alone is not unique in the dom. example: id="level-1-row-216" I am storing the levels and rows of the visible elements in a cookie, so that when the page reloads the same rows the user had open are can be shown automatically. I don't store the full map of dom ids, because I'm concerned about it getting too verbose, and I want to keep my cookie under 4Kb. So I convert the dom ids to a compact json object like this, with one property for each level, and a unique array of primary keys under each level: { 1:[231,432,7656], 2:[234,121], 3:[234,2], 4:[222,423], 5:[222] } With this structure stored in a cookie, I feed it to my show function and restore the user's previous disclosure state when the page loads. The area for improvement: I'm looking for better option for reducing my map of id selectors down to this compact format. Here is my function: function getVisibleIds(){ // example dom id: level-1-row-216-sub var ids = $("tr#[id^=level]:visible").map(function() { return this.id; }); var levels = {}; for(var i in ids ) { var id = ids[i]; if (typeof id == 'string'){ if (id.match(/^level/)){ // here we extract the number for level and row var level = id.replace(/.*(level-)(\d*)(.*)/, '$2'); var row = id.replace(/.*(row-)(\d*)(.*)/, '$2'); // *** Improvement here? *** // This works, but it seems klugy. In PHP it's one line (see below): if(levels.hasOwnProperty(level)){ if($.inArray(parseInt(row, 10) ,levels[level]) == -1){ levels[level].push(parseInt(row, 10)); } } else { levels[level] = [parseInt(row, 10)]; } } } } return levels; } If I were doing it in PHP, I'd build the compact array like this, but I can't figure it out in javascript: foreach($ids as $id) { if (/* the criteria */){ $level = /* extract it from $id */; $row = /* extract it from $id */; $levels[$level][$row]; } }

    Read the article

  • Marking multi-level nested forms as "dirty" in Rails

    - by Charles Kihe
    I have a three-level multi-nested form in Rails. The setup is like this: Projects have many Milestones, and Milestones have many Notes. The goal is to have everything editable within the page with JavaScript, where we can add multiple new Milestones to a Project within the page, and add new Notes to new and existing Milestones. Everything works as expected, except that when I add new notes to an existing Milestone (new Milestones work fine when adding notes to them), the new notes won't save unless I edit any of the fields that actually belong to the Milestone to mark the form "dirty"/edited. Is there a way to flag the Milestone so that the new Notes that have been added will save? Edit: sorry, it's hard to paste in all of the code because there's so many parts, but here goes: Models class Project < ActiveRecord::Base has_many :notes, :dependent => :destroy has_many :milestones, :dependent => :destroy accepts_nested_attributes_for :milestones, :allow_destroy => true accepts_nested_attributes_for :notes, :allow_destroy => true, :reject_if => proc { |attributes| attributes['content'].blank? } end class Milestone < ActiveRecord::Base belongs_to :project has_many :notes, :dependent => :destroy accepts_nested_attributes_for :notes, :allow_destroy => true, :allow_destroy => true, :reject_if => proc { |attributes| attributes['content'].blank? } end class Note < ActiveRecord::Base belongs_to :milestone belongs_to :project scope :newest, lambda { |*args| order('created_at DESC').limit(*args.first || 3) } end I'm using an jQuery-based, unobtrusive version of Ryan Bates' combo helper/JS code to get this done. Application Helper def add_fields_for_association(f, association, partial) new_object = f.object.class.reflect_on_association(association).klass.new fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| render(partial, :f => builder) end end I render the form for the association in a hidden div, and then use the following JavaScript to find it and add it as needed. JavaScript function addFields(link, association, content, func) { var newID = new Date().getTime(); var regexp = new RegExp("new_" + association, "g"); var form = content.replace(regexp, newID); var link = $(link).parent().next().before(form).prev(); if (func) { func.call(); } return link; } I'm guessing the only other relevant piece of code that I can think of would be the create method in the NotesController: def create respond_with(@note = @owner.notes.create(params[:note])) do |format| format.js { render :json => @owner.notes.newest(3).all.to_json } format.html { redirect_to((@milestone ? [@project, @milestone, @note] : [@project, @note]), :notice => 'Note was successfully created.') } end end The @owner ivar is created in the following before filter: def load_milestone @milestone = @project.milestones.find(params[:milestone_id]) if params[:milestone_id] end def determine_owner @owner = load_milestone @owner ||= @project end Thing is, all this seems to work fine, except when I'm adding new notes to existing milestones. The milestone has to be "touched" in order for new notes to save, or else Rails won't pay attention.

    Read the article

  • Number nested ordered lists in HTML

    - by John
    Hi I have a nested ordered list. <ol> <li>first</li> <li>second <ol> <li>second nested first element</li> <li>second nested secondelement</li> <li>second nested thirdelement</li> </ol> </li> <li>third</li> <li>fourth</li> </ol> Currently the nested elements start back from 1 again, e.g. first second second nested first element second nested second element second nested third element third fourth What I want is for the second element to be numbered like this: first second 2.1. second nested first element 2.2. second nested second element 2.3. second nested third element third fourth Is there a way of doing this? Thanks

    Read the article

  • nested ordered ol lists in html

    - by John
    Hi I have a nested ordered list. <ol> <li>first</li> <li>second <ol> <li>second nested first element</li> <li>second nested secondelement</li> <li>second nested thirdelement</li> </ol> </li> <li>third</li> <li>fourth</li> </ol> Currently the nested elements start back from 1 again, e.g. first second second nested first element second nested second element second nested third element third fourth What I want is for the second elements to be like this: first second 2.1. second nested first element 2.2. second nested second element 2.3. second nested third element third fourth Is there a way of doing this? Thanks

    Read the article

  • Nested While Loop for mysql_fetch_array not working as I expected

    - by Ayush Saraf
    I m trying to make feed system for my website, in which i have got i data from the database using mysql_fetch_array system and created a while loop for mysql_fetch_array and inside tht loop i have repeated the same thing again another while loop, but the problem is that the nested while loop only execute once and dont repeat the rows.... here is the code i have used some function and OOP but u will get wht is the point! i thought of an alternative but not yet tried vaz i wanna the way out this way only i.e. using a for loopo insted of while loop that mite wrk... public function get_feeds_from_my_friends(){ global $Friends; global $User; $friend_list = $Friends->create_friend_list_ids(); $sql = "SELECT feeds.id, feeds.user_id, feeds.post, feeds.date FROM feeds WHERE feeds.user_id IN (". $friend_list. ") ORDER BY feeds.id DESC"; $result = mysql_query($sql); while ($rows = mysql_fetch_array($result)) { $id = $rows['user_id']; $dp = $User->user_detail_by_id($id, "dp"); $user_name = $User->full_name_by_id($id); $post_id = $rows['id']; $final_result = "<div class=\"sharedItem\">"; $final_result .= "<div class=\"item\">"; $final_result .= "<div class=\"imageHolder\"><img src=\"". $dp ."\" class=\"profilePicture\" /></div>"; $final_result .= "<div class=\"txtHolder\">"; $final_result .= "<div class=\"username\"> " . $user_name . "</div>"; $final_result .= "<div class=\"userfeed\"> " . $rows['post'] . "</div>"; $final_result .= "<div class=\"details\">" . $rows['date'] . "</div>"; $final_result .= "</div></div>"; $final_result .= $this->get_comments_for_feed($post_id); $final_result .= "</div>"; echo $final_result; } } public function get_comments_for_feed($feed_id){ global $User; $sql = "SELECT feeds.comments FROM feeds WHERE feeds.id = " . $feed_id . " LIMIT 1"; $result = mysql_query($sql); $result = mysql_fetch_array($result); $result = $result['comments']; $comment_list = get_array_string_from_feild($result); $sql = "SELECT comment_feed.user_id, comment_feed.comment, comment_feed.date FROM comment_feed "; $sql .= "WHERE comment_feed.id IN(" . $comment_list . ") ORDER BY comment_feed.date DESC"; $result = mysql_query($sql); if(empty($result)){ return "";} else { while ($rows = mysql_fetch_array($result)) { $id = $rows['user_id']; $dp = $User->user_detail_by_id($id, "dp"); $user_name = $User->full_name_by_id($id); return "<div class=\"comments\"><div class=\"imageHolder\"><img src=\"". $dp ."\" class=\"profilePicture\" /></div> <div class=\"txtHolder\"> <div class=\"username\"> " . $user_name . "</div> <div class=\"userfeed\"> " . $rows['comment'] . "</div> <div class=\"details\">" . $rows['date'] . "</div> </div></div>"; } } }

    Read the article

  • User jQuery to get nested elements from XML

    - by Dkong
    I'm spinning my wheels on this. How do I get the values from the following nested elements from the XML below (I've also put my code below)? I am after the "descShort" value and then the capital "Last" and capital "change" : <indices> <index> <code>DJI</code> <exchange>NYSE</exchange> <liveness>DELAYED</liveness> <indexDesc> <desc>Dow Jones Industrials</desc> <descAbbrev>DOW JONES</descAbbrev> <descShort>DOW JONES</descShort> <firstActive></firstActive> <lastActive></lastActive> </indexDesc> <indexQuote> <capital> <first>11144.57</first> <high>11153.79</high> <low>10973.92</low> <last>11018.66</last> <change>-125.9</change> <pctChange>-1.1%</pctChange> </capital> <gross> <first>11144.57</first> <high>11153.79</high> <low>10973.92</low> <last>11018.66</last> <change>-125.9</change> <pctChange>-1.1%</pctChange> </gross> <totalEvents>4</totalEvents> <lastChanged>16-Apr-2010 16:03:00</lastChanged> </indexQuote> </index> <index> <code>XAO</code> <exchange>ASX</exchange> <liveness>DELAYED</liveness> <indexDesc> <desc>ASX All Ordinaries</desc> <descAbbrev>All Ordinaries</descAbbrev> <descShort>ALL ORDS</descShort> <firstActive>06-Mar-1970</firstActive> <lastActive></lastActive> </indexDesc> <indexQuote> <capital> <first>5007.30</first> <high>5007.30</high> <low>4934.00</low> <last>4939.40</last> <change>-67.9</change> <pctChange>-1.4%</pctChange> </capital> <gross> <first>5007.30</first> <high>5007.30</high> <low>4934.00</low> <last>4939.40</last> <change>-67.9</change> <pctChange>-1.4%</pctChange> </gross> <totalEvents>997</totalEvents> <lastChanged>19-Apr-2010 17:02:54</lastChanged> </indexQuote> </index> $.ajax({ type: "GET", url: "stockindices.xml", dataType: "xml", success: function(xml) { $(xml).find('index').each(function(){ var self = $(this); var code = self.find('indexDesc'); $(code).find('indexDesc').each(function(){ alert(self.find('descShort').text()); }); $('<span class=\"tickerItem\"></span>').html(values[0].text()).appendTo('#marq'); }); } });

    Read the article

  • PHP: Formatting multi-dimensional array as HTML?

    - by Industrial
    Hi everybody, I have tried to get my head around building a recursive function to handle formatting of a unknown depth multi-dimensional array to HTML and nested Divs. I thought that it should be a piece of cake, but no. Here's what I have come up with this far: function formatHtml($array) { $var = '<div>'; foreach ($array as $k => $v) { if (is_array($v['children']) && !empty($v['children'])) { formatHtml($v['children']); } else { $var .= $v['cid']; } } $var.= '</div>'; return $var; } And here's my array: Array ( [1] => Array ( [cid] => 1 [_parent] => [id] => 1 [name] => 'Root category' [children] => Array ( [2] => Array ( [cid] => 2 [_parent] => 1 [id] => 3 [name] => 'Child category' [children] => Array () ) ) ) ) Thanks a lot!

    Read the article

  • Problem with routes in functional testing

    - by Wishmaster
    Hi, I'm making a simple test project to prepare myself for my test. I'm fairly new to nested resources, in my example I have a newsitem and each newsitem has comments. The routing looks like this: resources :comments resources :newsitems do resources :comments end I'm setting up the functional tests for comments at the moment and I ran into some problems. This will get the index of the comments of a newsitem. @newsitem is declared in the setup ofc. test "should get index" do get :index,:newsitem_id => @newsitem assert_response :success assert_not_nil assigns(:newsitem) end But the problem lays here, in the "should get new". test "should get new" do get new_newsitem_comment_path(@newsitem) assert_response :success end I'm getting the following error. ActionController::RoutingError: No route matches {:controller=>"comments", :action=>"/newsitems/1/comments/new"} But when I look into the routes table, I see this: new_newsitem_comment GET /newsitems/:newsitem_id/comments/new(.:format) {:action=>"new", :controller=>"comments"} Can't I use the name path or what I'm doing wrong here? Thanks in advance.

    Read the article

  • Nested SQL Select statement fails on SQL Server 2000, ok on SQL Server 2005

    - by Jay
    Here is the query: INSERT INTO @TempTable SELECT UserID, Name, Address1 = (SELECT TOP 1 [Address] FROM (SELECT TOP 1 [Address] FROM [UserAddress] ua INNER JOIN UserAddressOrder uo ON ua.UserID = uo.UserID WHERE ua.UserID = u.UserID ORDER BY uo.AddressOrder ASC) q ORDER BY AddressOrder DESC), Address2 = (SELECT TOP 1 [Address] FROM (SELECT TOP 2 [Address] FROM [UserAddress] ua INNER JOIN UserAddressOrder uo ON ua.UserID = uo.UserID WHERE ua.UserID = u.UserID ORDER BY uo.AddressOrder ASC) q ORDER BY AddressOrder DESC) FROM User u In this scenario, users have multiple address definitions, with an integer field specifying the preferred order. "Address2" (the second preferred address) attempts to take the top two preferred addresses, order them descending, then take the top one from the result. You might say, just use a subquery which does a SELECT for the record with "2" in the Order field, but the Order values are not contiguous. How can this be rewritten to conform to SQL 2000's limitations? Very much appreciated.

    Read the article

  • MVVM pattern and nested view models - communication and lookup lists

    - by LostInWPF
    I am using Prism for a new application that I am creating. There are several lookup lists that will be used in several places in the application. Therefore it makes sense to define it once and use that everywhere I need that functionality. My current solution is to use typed data templates to render the controls inside a content control. <DataTemplate DataType={x:Type ListOfCountriesViewModel}> <ComboBox ItemsSource={Binding Countries} SelectedItem="{Binding SelectedCountry"/> </DataTemplate> <DataTemplate DataType={x:Type ListOfRegionsViewModel}> <ComboBox ItemsSource={Binding Countries} SelectedItem={Binding SelectedRegion} /> </DataTemplate> public class ParentViewModel { SelectedCountry get; set; SelectedRegion get; set; ListOfCountriesViewModel CountriesVM; ListOfRegionsViewModel RgnsVM; } Then in my window I have 2 content controls and the rest of the controls <ContentControl Content="{Binding CountriesVM}"></ContentControl> <ContentControl Content="{Binding RgnsVM}"></ContentControl> <Rest of controls on view> At the moment I have this working and the SelectedItems for the combo boxes are publising events via EventAggregator from the child view models which are then subscribed to in the parent view model. I am not sure that this is the best way to go as I can imagine I would end up with a lot of events very quickly and it will become unwieldy. Also if I was to use the same view model on another window it will publish the event and this parent viewmodel is subscribed to it which could have unintended consequences. My questions are :- Is this the best way to put lookup lists in a view which can be re-used across screens? How do I make it so that the combobox which is bound to the child viewmodel sets the relevant property on the parent viewmodel without using events / mediator. e.g in this case SelectedCountry for example? Any alternative implementation proposals for what I am trying to do? I have a feeling I am missing something obvious and there is so much info it is hard to know what is right so any help would be most gratefully received.

    Read the article

  • jquery nested sortable list

    - by Y.G.J
    i have this code $(document).ready(function() { $("#test-list").sortable({ items: "> li", handle : '.handle', axis: 'y', opacity: 0.6, update : function () { var order = $('#test-list').sortable('serialize'); $("#info").load("process-sortable.asp?"+order+"&id=catid&order=orderid&table=tblCats"); } }); $("#test-sub").sortable({ containment: "ul", items: "li", handle : '.handle', axis: 'y', opacity: 0.6, update : function () { var order = $('#test-list').sortable('serialize'); $("#info").load("process-sortable.asp?"+order+"&id=catid&order=orderid&table=tblCats"); } }); }); for this kind of UL <ul id="test-list"> <li></li> <li> <ul id="test-sub"> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> </ul> </li> <li></li> <li></li> <li></li> <li></li> </ul> but it can be changed dynamiclly... when i drag and drop the main li it is working when i do it with the childs it will drag the main one what is wrong?

    Read the article

  • Nested WHILE loops in Python

    - by Guru
    I am a beginner with Python and trying few programs. I have something like the following WHILE loop construct in Python (not exact). IDLE 2.6.4 >>> a=0 >>> b=0 >>> while a < 4: a=a+1 while b < 4: b=b+1 print a, b 1 1 1 2 1 3 1 4 I am expecting the outer loop to loop through 1,2,3 and 4. And I know I can do this with FOR loop like this >>> for a in range(1,5): for b in range(1,5): print a,b 1 1 1 2 1 3 1 4 2 1 2 2 2 3 2 4 3 1 3 2 3 3 3 4 4 1 4 2 4 3 4 4 But, what is wrong with WHILE loop? I guess I am missing some thing obvious, but could not make out. P.S: Searched out SO, found few questions but none as close to this. Don't know whether this could classified as homework, the actual program was different, the problem is what puzzles me.

    Read the article

  • Jquery - $(this) in in nested loops

    - by Smickie
    Hi, I can't figure out how to do something in Jquery. Let's say I have a form with many select drop-downs and do this... $('#a_form select').each(function(index) { }); When inside this loop I want to loop over each of the options, but I can't figure out how to do this, is it something like this....? $('#a_form select').each(function(index) { $(this + 'option').each(function(index) { //do things }); }); I can't quite get it to work, and advice? Cheers.

    Read the article

  • Using nested Master Pages

    - by abatishchev
    Hi. I'm very new to ASP.NET, help me please understand MasterPages conception more. I have Site.master with common header data (css, meta, etc), center form (blank) and footer (copyright info, contact us link, etc). <%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="_SiteMaster" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="tagHead" runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="styles.css" type="text/css" /> </head> <body> <form id="frmMaster" runat="server"> <div> <asp:ContentPlaceHolder ID="holderForm" runat="server"></asp:ContentPlaceHolder> <asp:ContentPlaceHolder ID="holderFooter" runat="server">Some footer here</asp:ContentPlaceHolder> </div> </form> </body> </html> and I want to use second master page for a project into sub directory, which would contains SQL query on Page_Load for logging (it isn't necessary for whole site). <%@ Master Language="C#" AutoEventWireup="true" CodeFile="Project.master.cs" Inherits="_ProjectMaster" MasterPageFile="~/Site.master" %> <asp:Content ContentPlaceHolderID="holderForm" runat="server"> <asp:ContentPlaceHolder ID="holderForm" runat="server" EnableViewState="true"></asp:ContentPlaceHolder> </asp:Content> <asp:Content ContentPlaceHolderID="holderFooter" runat="server"> <asp:ContentPlaceHolder ID="holderFooter" runat="server" EnableViewState="true"></asp:ContentPlaceHolder> </asp:Content> But I have a problem: footer isn't displayed. Where is my mistake? Am I right to use second master page as super class for logging? Project page looks like this: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" MasterPageFile="~/Project.master" %> <asp:Content ContentPlaceHolderID="holderForm" runat="server"> <p>Hello World!</p> </asp:Content> <asp:Content ContentPlaceHolderID="holderFooter" runat="Server"> Some footer content </asp:Content>

    Read the article

  • How to use regex to extract nested patterns

    - by Rob Romanek
    Hi I'm struggling with some regex I've got a string like this: a:b||c:{d:e||f:g}||h:i basically name value pairings. I want to be able to parse out the pairings so I get: a:b c:{d:e||f:g} h:i then I can further parse the pairings contained in { } if required It is the nesting that is making me scratch my head. Any regex experts out there that can give me a hand? thanks, Rob

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >