Search Results

Search found 2815 results on 113 pages for 'statements'.

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

  • How to UNION ALL two SELECT statements?

    - by Lisa
    I have 2 tables, one looks like this: TABLE ONE id | Last Name | First Name | Username | Password | Secret Question and another that looks like this: TABLE TWO id | Hobby | Country | I want to combine a Select statement that grabs data from both tables and output the results. The following code: $select = mysql_query(" SELECT * FROM table_one WHERE Username = 'Bob' UNION ALL SELECT * FROM table_two WHERE Hobby = 'Baseball' "); while ($return = mysql_fetch_assoc($select)) { $userName = $return['Username']; $hobby = $return['Hobby']; } echo "$userName likes $hobby"; results in a The used SELECT statements have a different number of columns error, what am I doing wrong?

    Read the article

  • Execute Statements in a Transaction - Sql Server 2005

    - by Shrewd Demon
    hi, i need to update a database where some of the table have changed (columns have been added). I want to perform this action in a proper transaction. If the code executes without any problem then i will commit the changes otherwise i will rollback the database back to its original state. I want to do something like this: BEGIN TRANSACTION ...Execute some sql statements here COMMIT TRANSACTION (When every thing goes well) ROLLBACK TRANSACTION (When something goes wrong) Please tell me what is the best way to do this i know there is a @@TranCount variable but dont know its exact purpose. Thanks.

    Read the article

  • VBScript - using IF statements in a mail script?

    - by Kenny Bones
    I really need some quick tips here. I've got this VBScript script which sends an e-mail. And I want to do several checks to see if an attribute is true and if it is, write an additional line in the mail. How can I do this? This is part of the script: obMessage.HTMLBody = ""_ & "<MENU>"_ & "<LI type = square>This is a line</i>."_ I want something which looks like this: obMessage.HTMLBody = ""_ & "<MENU>"_ If statement1 = true Then & "<LI type = square>This is an additional line</i>."_ end if Preferrably, could some select statements be made? I don't really mind what the code looks like, I just want it to work as soon as possible :)

    Read the article

  • Where Should Using Statements Be Located [closed]

    - by Bobby Ortiz - DotNetBob
    Possible Duplicate: What is the difference between these two declarations? I recently started working on a project with using statement located inside the NameSpace block. namespace MyApp.Web { using System; using System.Web.Security; using System.Web; public class MyClass { I usually put my using statements above the namespace block. using System; using System.Web.Security; using System.Web; namespace MyApp.Web { public class MyClass { I don't think it matters, but I am currious if someone else had a recommendation and could they explain why one way is better than another. Note: I always have one class per file.

    Read the article

  • Oracle 10g multiple DELETE statements

    - by bmw0128
    I'm building a dml file that first deletes records that may be in the table, then inserts records. Example: DELETE from foo where field1='bar'; DELETE from foo where fields1='bazz'; INSERT ALL INTO foo(field1, field2) values ('bar', 'x') INTO foo(field1, field2) values ('bazz', 'y') SELECT * from DUAL; When I run the insert statement by itself, it runs fine. When I run the deletes, only the last delete runs. Also, it seems to be necessary to end the multiple insert with the select, is that so? If so, why is that necessary? In the past, when using MySQL, I could just list multiple delete and insert statements, all individually ending with a semicolon, and it would run fine.

    Read the article

  • python: importing modules with incorrect import statements => unexhaustive info from resulting Impor

    - by bbb
    Hi there, I have a funny problem I'd like to ask you guys ('n gals) about. I'm importing some module A that is importing some non-existent module B. Of course this will result in an ImportError. This is what A.py looks like import B Now let's import A >>> import A Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/tmp/importtest/A.py", line 1, in <module> import B ImportError: No module named B Alright, on to the problem. How can I know if this ImportError results from importing A or from some corrupt import inside A without looking at the error's string representation. The difference is that either A is not there or does have incorrect import statements. Hope you can help me out... Cheers bb

    Read the article

  • Executing multiple update statements in PHP

    - by theband
    I have three update statements to be executed in PHP, i am getting the values of all these as return parameters. How to execute each statement independely and finally show the end user the result that it has been successfully updated. <?php public function name($parameter1,$parameter2.... $parametern) { $records=array(); $sql=""; $sql2=""; $sql3=""; $result=mysql_query($sql); //return $result; if(!$result){throw new Exception(mysql_error());} if(mysql_num_rows($result)==0){return $records;} while($row=mysql_fetch_assoc($result)){$records[]=$row;} return $records; } ?> Then how finally we can get the result in my row object.

    Read the article

  • SQL 2000 Multiple IF Statements

    - by Spidermain50
    I get a error when I try to use multiple IF statements. This is the error... "Msg 156, Level 15, State 1, Procedure fnTNAccidentIndicator, Line 81 Incorrect syntax near the keyword 'END'." This is the structure of my code... USE SS_TNRecords_Accident SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE FUNCTION dbo.fnTNAccidentIndicator ( @inAccidentNumber nvarchar, @inIndicatorMode int ) RETURNS nvarchar AS BEGIN DECLARE @AlcoholInd nvarchar DECLARE @DrugInd nvarchar DECLARE @SpeedInd nvarchar DECLARE @ReturnValue nvarchar SET @AlcoholInd = '1' SET @DrugInd = '2' SET @SpeedInd = '3' SET @ReturnValue = 'N' IF (@inIndicatorMode = @AlcoholInd) BEGIN --select statment IF (@@ROWCOUNT > 0) BEGIN @ReturnValue = 'Y' END END IF (@inIndicatorMode = @DrugInd) BEGIN --select statment IF (@@ROWCOUNT > 0) BEGIN @ReturnValue = 'Y' END END IF (@inIndicatorMode = @SpeedInd) BEGIN --select statment IF (@@ROWCOUNT > 0) BEGIN @ReturnValue = 'Y' END END Return @ReturnValue END GO

    Read the article

  • What are these c++ statements doing

    - by codingguy3000
    void useproxynum ( ) { bUseProxy = true; return; }; void useacctnum ( ) { bUseProxy = false; return; }; Can anyone give me some insight into what these c++ statements are doing? There are in a header file. bUseProxy is defined above bool bUseProxy; I'm trying to figure out what useproxynum is (method call?) and I'm also trying to figure out how to find the code behind it. This is in Visual Studio 6.

    Read the article

  • Nesting if else statements in PHP to validate a URL

    - by John
    I'm currently writing up a function in order to validate a URL by exploding it into different parts and matching those parts with strings I've defined. This is the function I'm using so far: function validTnet($tnet_url) { $tnet_2 = "defined2"; $tnet_3 = "defined3"; $tnet_5 = "defined5"; $tnet_7 = ""; if($exp_url[2] == $tnet_2) { #show true, proceed to next validation if($exp_url[3] == $tnet_3) { #true, and next if($exp_url[5] == $tnet_5) { #true, and last if($exp_url[7] == $tnet_7) { #true, valid } } } } else { echo "failed on tnet_2"; } } For some reason I'm unable to think of the way to code (or search for the proper term) of how to break out of the if statements that are nested. What I would like to do check each part of the URL, starting with $tnet_2, and if it fails one of the checks ($tnet_2, $tnet_3, $tnet_5 or $tnet_7), output that it fails, and break out of the if statement. Is there an easy way to accomplish this using some of the code I have already?

    Read the article

  • Where should 'CreateMap' statements go?

    - by jonathanconway
    I frequently use AutoMapper to map Model (Domain) objects to ViewModel objects, which are then consumed by my Views, in a Model/View/View-Model pattern. This involves many 'Mapper.CreateMap' statements, which all must be executed, but must only be executed once in the lifecycle of the application. Technically, then, I should keep them all in a static method somewhere, which gets called from my Application_Start() method (this is an ASP.NET MVC application). However, it seems wrong to group a lot of different mapping concerns together in one central location. Especially when mapping code gets complex and involves formatting and other logic. Is there a better way to organize the mapping code so that it's kept close to the ViewModel that it concerns? (I came up with one idea - having a 'CreateMappings' method on each ViewModel, and in the BaseViewModel, calling this method on instantiation. However, since the method should only be called once in the application lifecycle, it needs some additional logic to cache a list of ViewModel types for which the CreateMappings method has been called, and then only call it when necessary, for ViewModels that aren't in that list.)

    Read the article

  • Bash Shell Script: Nested Select Statements

    - by CCG121
    I have A Script that has a Select statement to go to multiple sub select statements however once there I can not seem to figure out how to get it to go back to the main script. also if possible i would like it to re-list the options #!/bin/bash PS3='Option = ' MAINOPTIONS="Apache Postfix Dovecot All Quit" APACHEOPTIONS="Restart Start Stop Status" POSTFIXOPTIONS="Restart Start Stop Status" DOVECOTOPTIONS="Restart Start Stop Status" select opt in $MAINOPTIONS; do if [ "$opt" = "Quit" ]; then echo Now Exiting exit elif [ "$opt" = "Apache" ]; then select opt in $APACHEOPTIONS; do if [ "$opt" = "Restart" ]; then sudo /etc/init.d/apache2 restart elif [ "$opt" = "Start" ]; then sudo /etc/init.d/apache2 start elif [ "$opt" = "Stop" ]; then sudo /etc/init.d/apache2 stop elif [ "$opt" = "Status" ]; then sudo /etc/init.d/apache2 status fi done elif [ "$opt" = "Postfix" ]; then select opt in $POSTFIXOPTIONS; do if [ "$opt" = "Restart" ]; then sudo /etc/init.d/postfix restart elif [ "$opt" = "Start" ]; then sudo /etc/init.d/postfix start elif [ "$opt" = "Stop" ]; then sudo /etc/init.d/postfix stop elif [ "$opt" = "Status" ]; then sudo /etc/init.d/postfix status fi done elif [ "$opt" = "Dovecot" ]; then select opt in $DOVECOTOPTIONS; do if [ "$opt" = "Restart" ]; then sudo /etc/init.d/dovecot restart elif [ "$opt" = "Start" ]; then sudo /etc/init.d/dovecot start elif [ "$opt" = "Stop" ]; then sudo /etc/init.d/dovecot stop elif [ "$opt" = "Status" ]; then sudo /etc/init.d/dovecot status fi done elif [ "$opt" = "All" ]; then sudo /etc/init.d/apache2 restart sudo /etc/init.d/postfix restart sudo /etc/init.d/dovecot restart fi done

    Read the article

  • Regex statements for date ranges <=4/1/2009 and <=10/01/2009

    - by reggiereg
    Hi, I need serious help building two Regex statements for a project. The software we're using ONLY accepts Regex for validation. I need one that fires for any date <4/1/2009 and a second that fires for any date <10/1/2009 My co-worker gave me the following code to check for <=10/01/2010, but it checks leap years and all that stuff. I need something a little more streamlined than this in the MM/DD/YYYY format. Thanks in advance! ^(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|.)(?:0?[1-9]|1\d|2[0-8])(\/|-|.)(?:2[0-9][2-9][0-9])$|^(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|.)(?:0?[1-9]|1\d|2[0-8])(\/|-|.)(?:201[1-9])$|^(?:(?:(?:0?[13578]|1[02])(\/|-|.)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-|.)(?:29|30)))(\/|-|.)(?:201[1-9])$|^(?:(?:(?:11)(\/|-|.))(?:0?[1-9]|1\d|2[0-9]|30)(\/|-|.))(2010)$|^(?:(?:(?:10|12)(\/|-|.))(?:0?[1-9]|1\d|2[0-9]|30|31)(\/|-|.))(2010)$|^(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|.)(?:0?[1-9]|1\d|2[0-8])(\/|-|.)(?:2[0-9][2-9][0-9])$|^(?:(?:(?:0?[13578]|1[02])(\/|-|.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|.)(?:29|30)))(\/|-|.)(?:2[0-9][2-9][0-9])$|^(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|.)(?:0?[1-9]|1\d|2[0-8])(\/|-|.)(?:2011)$|^(?:0?2(\/|-|.)29\3(?:(?:(?:2[0-9][1-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$

    Read the article

  • Generating MySQL UPDATE statements containing BLOB image data

    - by Bob
    I'm trying to write an SQL statement that will generate an SQL script that will update a BLOB field with an IMAGE being selected from the database. This is what I have: select concat( 'UPDATE `IMAGE` SET THUMBNAIL = ', QUOTE( THUMBNAIL ), ' WHERE ID = ', ID, ';' ) as UPDATE_STATEMENT from IMAGE; In the above, THUMBNAIL is a BLOB field containing raw image data. When I run the resulting script I get the following error: ERROR at line 2: Unknown command '\\'. I first tried this without the QUOTE() function, like so: select concat( 'UPDATE `IMAGE` SET THUMBNAIL = \'', THUMBNAIL, '\' WHERE ID = ', ID, ';' ) as UPDATE_STATEMENT from IMAGE; Running the resulting script produces this error: ERROR at line 2: Unknown command '\0'. What is the proper function to apply to this BLOB field in the select, so the UPDATE statements will work? If context is required, I'm looking to migrate thumbnails generated on one server to another server for certain image IDs only. I would use mysqldump, but I don't want to clobber the entire table. Any help is greatly appreciated!

    Read the article

  • Getting rid of nested using(...) statements

    - by Ghostrider
    Sometimes I need to use several disposable objects within a function. Most common case is having StreamReader and StreamWriter but sometimes it's even more than this. Nested using statements quickly add up and look ugly. To remedy this I've created a small class that collects IDisposable objects and disposes of them when it itself is disposed. public class MultiDispose : HashSet<IDisposable>, IDisposable { public MultiDispose(params IDisposable[] objectsToDispose) { foreach (IDisposable d in objectsToDispose) { this.Add(d); } } public T Add<T>(T obj) where T : IDisposable { base.Add(obj); return obj; } public void DisposeObject(IDisposable obj) { obj.Dispose(); base.Remove(obj); } #region IDisposable Members public void Dispose() { foreach (IDisposable d in this) { d.Dispose(); } } #endregion } So my code now looks like this: using (MultiDispose md = new MultiDispose()) { StreamReader rdr = md.Add(new StreamReader(args[0])); StreamWriter wrt = md.Add(new StreamWriter(args[1])); WhateverElseNeedsDisposing w = md.Add(new WhateverElseNeedsDisposing()); // code } Is there anything wrong with this approach that can cause problems down the road? I left the Remove function inherited from the HashSet on purpose so that the class would be more flexible. Surely misusing this function can lead to objects not being disposed of properly, but then there many other ways to shoot yourself in the foot without this class.

    Read the article

  • Query with many CASE statements - optimization

    - by Nemanja Vujacic
    Hi guys, I have one very dirty query that per sure can be optimized because there are so many CASE statements in it! SELECT (CASE pa.KplusTable_Id WHEN 1 THEN sp.sp_id WHEN 2 THEN fw.fw_id WHEN 3 THEN s.sw_Id WHEN 4 THEN id.ia_id END) as Deal_Id, max(CASE pa.KplusTable_Id WHEN 1 THEN sp.Trans_Id WHEN 2 THEN fw.Trans_Id WHEN 3 THEN s.Trans_Id WHEN 4 THEN id.Trans_Id END) as TransId_CurrentMax INTO #MaxRazlicitOdNull FROM #PotencijalniAktuelni pa LEFT JOIN kplus_sp sp (nolock) on sp.sp_id=pa.Deal_Id AND pa.KplusTable_Id=1 LEFT JOIN kplus_fw fw (nolock) on fw.fw_id=pa.Deal_Id AND pa.KplusTable_Id=2 LEFT JOIN dev_sw s (nolock) on s.sw_Id=pa.Deal_Id AND pa.KplusTable_Id=3 LEFT JOIN kplus_ia id (nolock) on id.ia_id=pa.Deal_Id AND pa.KplusTable_Id=4 WHERE isnull(CASE pa.KplusTable_Id WHEN 1 THEN sp.BROJ_TIKETA WHEN 2 THEN fw.BROJ_TIKETA WHEN 3 THEN s.tiket WHEN 4 THEN id.BROJ_TIKETA END, '')<>'' GROUP BY CASE pa.KplusTable_Id WHEN 1 THEN sp.sp_id WHEN 2 THEN fw.fw_id WHEN 3 THEN s.sw_Id WHEN 4 THEN id.ia_id END Because I have same condition couple times, do you have idea how to optimize query, make it simpler and better. All suggestions are welcome! TnX in advance! Nemanja

    Read the article

  • Problem with checkboxes, sql select statements & php

    - by smokey20
    I am trying to display some rows from a database table based on choices submitted by the user. Here is my form code <form action="choice.php" method="POST" > <input type="checkbox" name="variable[]" value="Apple">Apple <input type="checkbox" name="variable[]" value="Banana">Banana <input type="checkbox" name="variable[]" value="Orange">Orange <input type="checkbox" name="variable[]" value="Melon">Melon <input type="checkbox" name="variable[]" value="Blackberry">Blackberry From what I understand I am placing the values of these into an array called variable. Two of my columns are called receipe name and ingredients(each field under ingredients can store a number of fruits). What I would like to do is, if a number of checkboxes are selected then the receipe name/s is displayed. Here is my php code. <?php // Make a MySQL Connection mysql_connect("localhost", "*****", "*****") or die(mysql_error()); mysql_select_db("****") or die(mysql_error()); $variable=$_POST['variable']; foreach ($variable as $variablename) { echo "$variablename is checked"; } $query = "SELECT receipename FROM fruit WHERE $variable like ingredients"; $row = mysql_fetch_assoc($result); foreach ($_POST['variabble'] as $ingredients) echo $row[$ingredients] . '<br/>'; ?> I am very new to php and just wish to display the data, I do not need to perform any actions on it. I have tried many select statements but I cannot get any results to display. My db connection is fine and it does print out what variables are checked. Many thanks in advance.

    Read the article

  • Code refactoring c# question around several if statements performing the same check

    - by James Radford
    I have a method that has a load of if statements that seems a bit silly although I'm not sure how to improve the code. Here's an example. This logic was inside the view which is now in the controller which is far better but is there something I'm missing, maybe a design pattern that stops me having to check against panelCount < NumberOfPanelsToShow and handling the panelCount every condition? Maybe not, just feels ugly! Many thanks if (model.Train && panelCount < NumberOfPanelsToShow) { panelTypeList.Add(TheType.Train); panelCount++; } if (model.Car && panelCount < NumberOfPanelsToShow) { panelTypeList.Add(TheType.Car); panelCount++; } if (model.Hotel && panelCount < NumberOfPanelsToShow) { panelTypeList.Add(TheType.Hotel); panelCount++; } ...

    Read the article

  • If Statements Skipping or Evaluating Strangely, JavaScript and jquery

    - by tlm2021
    So in jQuery, I have a global variable "currentSubNav" that stores a current visible element. The following code executes on "mouseenter". I need it to get store element's ID, check to see if there was one. If there wasn't, set the new visible element to the default. $('#mainMenu a').mouseenter(function() { var newName = $(this).attr("id"); if(newName == ''){ var newName = "default"; } Then it checks to see if the new element matches the current one. If so, it returns. If not, it performs the animations to bring in the new one. if(newName == currentSubNav){ return; }else{ $("div[name=" + currentSubNav + "]").animate({"left": "+=600px", "opacity": "toggle"}, "slow"); $("div[name=" + newName + "]").css({"margin-top": "0"}); $("div[name=" + newName + "]").fadeIn(2000); $("div[name=" + currentSubNav + "]").animate({"left": "-=600px"}, 0); currentSubNav = newName; return; } }); I'm using Chrome at the moment, and according to the dev tools that isn't what happens. Problem #1 "$(this).attr("id");" isn't returning undefined as the documentation claims. It seems to be returning "". BUT, when I have the if statement as I do above, it skips over the statement entirely. I set a breakpoint, but it never pauses execuation, so the statement is never evaluated. Problem #2 After the animations occur, instead of using the return at the end of the statements it goes back and uses the return for the "newName == currentSubNav" if statement. I guess that not a big deal, but it's not the intended behavior. I'm fairly new to JavaScript, and it appears I'm missing something about how JavaScript works. But I can't find what anywhere. Any help? Blockquote

    Read the article

  • Large Switch statements: Bad OOP?

    - by Mystere Man
    I've always been of the opinion that large switch statements are a symptom of bad OOP design. In the past, I've read articles that discuss this topic and they have provided altnerative OOP based approaches, typically based on polymorphism to instantiate the right object to handle the case. I'm now in a situation that has a monsterous switch statement based on a stream of data from a TCP socket in which the protocol consists of basically newline terminated command, followed by lines of data, followed by an end marker. The command can be one of 100 different commands, so I'd like to find a way to reduce this monster switch statement to something more manageable. I've done some googling to find the solutions I recall, but sadly, Google has become a wasteland of irrelevant results for many kinds of queries these days. Are there any patterns for this sort of problem? Any suggestions on possible implementations? One thought I had was to use a dictionary lookup, matching the command text to the object type to instantiate. This has the nice advantage of merely creating a new object and inserting a new command/type in the table for any new commands. However, this also has the problem of type explosion. I now need 100 new classes, plus I have to find a way to interface them cleanly to the data model. Is the "one true switch statement" really the way to go? I'd appreciate your thoughts, opinions, or comments.

    Read the article

  • jQuery multiple if else Statements

    - by Chris MMgr
    I have a set of images that I am trying to activate (change opacity) based on the position of a user's window. The below code works, but only through a long series of if else statements. Is there a way to shorten the below code? //Function to activate and deactivate the buttons on the side menu function navIndicator() { var winNow = $(window).scrollTop(); var posRoi = $('#roi').offset(); var posRoiNow = posRoi.top; //Activate the propper button corresponding to what section the user is viewing if (winNow == posRoiNow * 0) { $('#homeBut a img.active').stop().animate({ opacity: 1 } { queue: false, duration: 300, easing: "easeOutExpo" }); $('#homeBut').addClass("viewing") } else { $('#homeBut a img.active').stop().animate({ opacity: 0 }, { queue: false, duration: 300, easing: "easeOutExpo" }); $('#homeBut').removeClass("viewing") } if (winNow == posRoiNow) { $('#roiBut a img.active').stop().animate({ opacity: 1 }, { queue: false, duration: 300, easing: "easeOutExpo" }); $('#roiBut').addClass("viewing") } else { $('#roiBut a img.active').stop().animate({ opacity: 0 }, { queue: false, duration: 300, easing: "easeOutExpo" }); $('#roiBut').removeClass("viewing") } if (winNow == posRoiNow * 2) { $('#dmsBut a img.active').stop().animate({ opacity: 1 }, { queue: false, duration: 300, easing: "easeOutExpo" }); $('#dmsBut').addClass("viewing") } else { $('#dmsBut a img.active').stop().animate({ opacity: 0 }, { queue: false, duration: 300, easing: "easeOutExpo" }); $('#dmsBut').removeClass("viewing") } if (winNow == posRoiNow * 3) { $('#techBut a img.active').stop().animate({ opacity: 1 }, { queue: false, duration: 300, easing: "easeOutExpo" }); $('#techBut').addClass("viewing") } else { $('#techBut a img.active').stop().animate({ opacity: 0 }, { queue: false, duration: 300, easing: "easeOutExpo" }); $('#techBut').removeClass("viewing") } if (winNow == posRoiNow * 4) { $('#impBut a img.active').stop().animate({ opacity: 1 }, { queue: false, duration: 300, easing: "easeOutExpo" }); $('#impBut').addClass("viewing") } else { $('#impBut a img.active').stop().animate({ opacity: 0 }, { queue: false, duration: 300, easing: "easeOutExpo" }); $('#impBut').removeClass("viewing") } if (winNow == posRoiNow * 5) { $('#virBut a img.active').stop().animate({ opacity: 1 }, { queue: false, duration: 300, easing: "easeOutExpo" }); $('#virBut').addClass("viewing") } else { $('#virBut a img.active').stop().animate({ opacity: 0 }, { queue: false, duration: 300, easing: "easeOutExpo" }); $('#virBut').removeClass("viewing") } if (winNow == posRoiNow * 6) { $('#biBut a img.active').stop().animate({ opacity: 1 }, { queue: false, duration: 300, easing: "easeOutExpo" }); $('#biBut').addClass("viewing") } else { $('#biBut a img.active').stop().animate({ opacity: 0 }, { queue: false, duration: 300, easing: "easeOutExpo" }); $('#biBut').removeClass("viewing") } if (winNow == posRoiNow * 7) { $('#contBut a img.active').stop().animate({ opacity: 1 }, { queue: false, duration: 300, easing: "easeOutExpo" }); $('#contBut').addClass("viewing") } else { $('#contBut a img.active').stop().animate({ opacity: 0 }, { queue: false, duration: 300, easing: "easeOutExpo" }); $('#contBut').removeClass("viewing") } };

    Read the article

  • Add a fadein fade out in jQuery, on multiple conditional statements

    - by Matthew Harwood
    Task: On click of li navigation filter show and hide content with a transitional fadein fade out. Problem I'm just guessing and checking on where to place this fadein//fadeout transition. Furthermore, I feel like my code is too inefficiency because I'm using 4 conditional statements. Would stack lead me in creating a solution to improve the overall logic of this script so I can just make a pretty transition :c? LIVE CODE jQuery Script $(document).ready(function () { //attach a single click listener on li elements $('li.navCenter').on('click', function () { // get the id of the clicked li var id = $(this).attr('id'); // match current id with string check then apply filter if (id == 'printInteract') { //reset all the boxes for muliple clicks $(".box").find('.video, .print, .web').closest('.box').show(); $(".box").find('.web, .video').closest('.box').hide(); $(".box").find('.print').show(); } if (id == 'webInteract') { $(".box").find('.video, .print, .web').closest('.box').show(); $(".box").find('.print, .video').closest('.box').hide(); $(".box").find('.web').show(); } if (id == 'videoInteract') { $(".box").find('.video, .print, .web').closest('.box').show(); $(".box").find('.print, .web').closest('.box').hide() $(".box").find('.video').show(); } if (id == 'allInteract') { $(".box").find('.video, .print, .web').closest('.box').show(); } }); HTML Selected <nav> <ul class="navSpaces"> <li id="allInteract" class="navCenter"> <a id="activeAll" class="navBg" href="#"><div class="relativeCenter"><img src="asset/img/logo30px.png" /><h3>all</h3></div></a> </li> <li id="printInteract" class="navCenter"> <a id="activePrint" class="navBg" href="#"><div class="relativeCenter"><img src="asset/img/print.gif" /><h3>print</h3></div></a> </li> <li id="videoInteract" class="navCenter"> <a id="activeVideo" class="navBg" href="#"><div class="relativeCenter"><img src="asset/img/video.gif" /><h3>video</h3></div></a> </li> <li id="webInteract" class="navCenter"> <a id="activeWeb" class="navBg" href="#"><div class="relativeCenter"><img src="asset/img/web.gif" /><h3>web</h3></div></a> </li> </ul> ps. Sorry for the newbie question

    Read the article

  • Using IF statements to find string length in array for alignment (Visual Basic)

    - by Brodoin
    My question is just as it says in the title. How would one use IF statements to find the string-length of content in an array, and then make it so that they show up in a Rich Text Box with the left sides aligned? Noting that one value in my array is a Decimal. Imports System.IO Imports System.Convert Public Class frmAll 'Declare Streamreader Private objReader As StreamReader 'Declare arrays to hold the information Private strNumber(24) As String Private strName(24) As String Private strSize(24) As String Private decCost(24) As Integer Private Sub frmAll_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Set objReader objReader = New StreamReader("products.csv") 'Call the FillArray sub to fill the array Call FillArray() End Sub Private Sub FillArray() 'Declare variables and arrays Dim decCost(24, 1) As Decimal Dim strFields() As String Dim strRec As String Dim intCount As Integer = 0 Dim chrdelim As Char = ToChar(",") 'Set strRec to read the lines strRec = objReader.ReadLine 'Do while loop to fill array. Do While strRec <> Nothing strFields = strRec.Split(chrdelim) strNumber(intCount) = strFields(0) strName(intCount) = strFields(1) strSize(intCount) = strFields(2) decCost(intCount, 0) = ToDecimal(strFields(3)) decCost(intCount, 1) = ToDecimal(strFields(4)) 'Set strRec to read the lines again strRec = objReader.ReadLine 'increment the index intCount += 1 Loop 'Call the Calculate sub for calculation Call Calculate(decCost) End Sub Private Sub Calculate(ByVal numIn(,) As Decimal) 'Define arrays to hold total cost Dim decRowTotal(24) As Decimal 'Define variables to hold the counters for rows and columns Dim intR As Integer Dim intC As Integer 'Calcualte total cost For intC = 0 To 1 For intR = 0 To 24 decRowTotal(intR) += numIn(intR, intC) * 1 Next Next 'Call the Output sub to configure the output. Call Output(numIn, decRowTotal) End Sub Private Sub Output(ByVal NumIn(,) As Decimal, _ ByVal RowTotalIn() As Decimal) 'Variables Dim strOut As String Dim intR As Integer = 0 Dim intC As Integer = 0 'Set header for output. strOut = "ID" & vbTab & "Item" & vbTab & vbTab & vbTab & "Size" & _ vbTab & vbTab & vbTab & vbTab & "Total Price" & _ vbCrLf & "---------- ... -------------------------" & vbCrLf 'For loop to add each line to strOut, setting 'the RowTotalIn to currency. For intC = 0 To 24 strOut &= strNumber(intC) & vbTab strOut &= strName(intC) & vbTab strOut &= strSize(intC) & vbTab strOut &= RowTotalIn(intC).ToString("c") & vbCrLf Next 'Add strOut to rbtAll rtbAll.Text = strOut End Sub End Class Output It shows up with vbTabs in my output, but still, it looks similar in that they are not aligned. The first two do, but after that they are not, and I am totally lost. P0001 Coffee - Colombian Supreme 24/Case: Pre-Ground 1.75 Oz Bags $16.50 P0002 Coffee - Hazelnut 24/Case: Pre-Ground 1.75 Oz Bags $24.00 P0003 Coffee - Mild Blend 24/Case: Pre-Ground 1.75 Oz Bags $20.50 P0004 Coffee - Assorted Flavors 18/Case. Pre-Ground 1.75 Oz Bags $23.50 P0005 Coffee - Decaf 24/Case: Pre-Ground 1.75 Oz Bags $20.50

    Read the article

  • C# LINQ filtering with nested if statements

    - by Tim Sumrall
    I have a learning project where a data grid is filtered by 3 controls (a checkbox and 2 dropdowns) I'm about to wrap up and move on to another project as it works well but I don't like the complexity of nesting IF statements to capture all the possible combinations of the 3 filters and was wondering if there is a better way. For example: Something that would allow for more filters to be added easily rather than walking through all the nests and adding another level of madness. private void BuildQuery() { EntityQuery<MASTER_DOCKS> query = QDocksContext.GetMASTER_DOCKSQuery(); if (Tonnage.IsChecked.HasValue && Tonnage.IsChecked.Value) { if (null != FilterWaterWay.SelectedValue) { string WaterwaytoFilterBy = FilterWaterWay.SelectedValue.ToString(); if (!string.IsNullOrWhiteSpace(WaterwaytoFilterBy) && WaterwaytoFilterBy != "[Select WaterWay]") { if (null != FilterState.SelectedValue) { string StateToFilterBy = FilterState.SelectedValue.ToString(); if (null != FilterState.SelectedValue && !string.IsNullOrWhiteSpace(StateToFilterBy) && StateToFilterBy != "[Select State]") { if (!string.IsNullOrWhiteSpace(StateToFilterBy) && StateToFilterBy != "[Select State]") { query = query.Where(s => s.WTWY_NAME == WaterwaytoFilterBy && s.STATE == StateToFilterBy && (s.Tons != "0" && s.Tons != "")).OrderBy(s => s.WTWY_NAME); MyQuery.Text = "Tonnage, WW and State"; } } if (StateToFilterBy == "[Select State]") //waterway but no state { query = query.Where(s => s.WTWY_NAME == WaterwaytoFilterBy && (s.Tons != "0" && s.Tons != "")).OrderBy(s => s.WTWY_NAME); MyQuery.Text = "Tonnage, WW No State"; } } } else { if (null != FilterState.SelectedValue) { string StateToFilterBy = FilterState.SelectedValue.ToString(); if (null != FilterState.SelectedValue && !string.IsNullOrWhiteSpace(StateToFilterBy) && StateToFilterBy != "[Select State]") { if (!string.IsNullOrWhiteSpace(StateToFilterBy) && StateToFilterBy != "[Select State]") { query = query.Where(s => s.STATE == StateToFilterBy && (s.Tons != "0" && s.Tons != "")).OrderBy(s => s.WTWY_NAME); MyQuery.Text = "Tonnage State No WW"; } } else { query = query.Where(s => (s.Tons != "0" && s.Tons != "")); MyQuery.Text = "Tonnage No State No WW"; } } } } } else //no tonnage { if (null != FilterWaterWay.SelectedValue) { string WaterwaytoFilterBy = FilterWaterWay.SelectedValue.ToString(); if (!string.IsNullOrWhiteSpace(WaterwaytoFilterBy) && WaterwaytoFilterBy != "[Select WaterWay]") { if (null != FilterState.SelectedValue) { string StateToFilterBy = FilterState.SelectedValue.ToString(); if (null != FilterState.SelectedValue && !string.IsNullOrWhiteSpace(StateToFilterBy) && StateToFilterBy != "[Select State]") { if (!string.IsNullOrWhiteSpace(StateToFilterBy) && StateToFilterBy != "[Select State]") { query = query.Where(s => s.WTWY_NAME == WaterwaytoFilterBy && s.STATE == StateToFilterBy).OrderBy(s => s.WTWY_NAME); MyQuery.Text = "No Tonnage, WW and State"; } } if (StateToFilterBy == "[Select State]") //waterway but no state { query = query.Where(s => s.WTWY_NAME == WaterwaytoFilterBy).OrderBy(s => s.WTWY_NAME); MyQuery.Text = "No Tonnage, WW No State"; } } } else { if (null != FilterState.SelectedValue) { string StateToFilterBy = FilterState.SelectedValue.ToString(); if (null != FilterState.SelectedValue && !string.IsNullOrWhiteSpace(StateToFilterBy) && StateToFilterBy != "[Select State]") { if (!string.IsNullOrWhiteSpace(StateToFilterBy) && StateToFilterBy != "[Select State]") { query = query.Where(s => s.STATE == StateToFilterBy).OrderBy(s => s.WTWY_NAME); MyQuery.Text = "No Tonnage State No WW"; } } else { LoadAllData(); MyQuery.Text = "No Tonnage No State No WW"; } } } } } LoadOperation<MASTER_DOCKS> loadOp = this.QDocksContext.Load(query); DocksGrid.ItemsSource = loadOp.Entities; }

    Read the article

  • Return cell reference as result of if statement with vlookups.

    - by EMJ
    I have two sets of data in excel. One contains a set of data which represents the initial step of a process. The other set of data represents the additional steps which take place after the first step is completed. Each of the data records in the "additional step data" has an id in a column. I need to find the identifying codes of the "additional step data" which correspond with the initial step data records. The problem is that I have to match the data in 4 columns between the two data sets and return the id of the "additional step data". I started by doing a combination of an if and vlookup functions, but I got stuck when I tried to figure out how to get the if statement to reference the id of the matching "additional step data". Basically I am trying to avoid having to search by manually filtering between two sets of data and finding corresponding records. Does anyone have any idea about how to do this?

    Read the article

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