Search Results

Search found 6988 results on 280 pages for 'if else statement'.

Page 43/280 | < Previous Page | 39 40 41 42 43 44 45 46 47 48 49 50  | Next Page >

  • 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

  • writing a shell script if statement to check for directory

    - by user1553248
    I need to write a script that will recreate my opt folder if it gets deleted when I remove a package from it. Here's a link to my previous post: dpkg remove to stop processes Now, the issue I'm running into could be better described here: http://lists.debian.org/debian-devel/2006/03/msg00242.html I was thinking of just adding a postrem script which checks if an opt directory exists, and if not, creates one. My experience with shell scripts is pretty limited though..

    Read the article

  • Determining an Oracle SQL MERGE statement result

    - by petejamd
    Follow up to this question This (similar version from old link) works in SQL Server 2008, however, Oracle is giving me trouble: MERGE INTO wdm_test USING ( select '10000000000000000000000000000000' Guid from DUAL ) val ON ( wdm_test.Guid = val.Guid ) WHEN MATCHED THEN UPDATE SET test_column = null WHEN NOT MATCHED THEN INSERT (Guid, test_column) VALUES ('10000000000000000000000000000000', null) OUTPUT $action; SQL Error: ORA-00933: SQL command not properly ended Does Oracle not support OUTPUT $action;? If not, is there an alternative?

    Read the article

  • sql statement to access sql

    - by Mitch Albert
    SELECT eventID, eventRedacteur, eventEvenement, eventGenreId, eventDatum, eventLocatieId, eventLocatieNaam, eventPlaatsId, eventBijzonderheden, eventBezoekers, lokId, lokNaam, lokUrl, pltsId, (SELECT pltsNaam FROM tblAgendaPlaatsen WHERE pltsId=tblAgendaPunten.eventPlaatsId) AS eventPlaatsNaam, (SELECT genreNaam FROM tblAgendaGenre WHERE genreId=tblAgendaPunten.eventGenreId) AS eventGenre, lokadres, lokhuisnr FROM tblAgendaPunten LEFT JOIN tblAgendaLocaties ON eventLocatieId=tblAgendaLocaties.lokId i get a join not supported error. I also tryed to remake the sql in access, but no luck. Anyone can help?

    Read the article

  • SQL 2008 CASE statement aggravation...

    - by Brad
    Why does this fail: DECLARE @DATE VARCHAR(50) = 'dasf' SELECT CASE WHEN ISDATE(@DATE) = 1 THEN CONVERT(date,@DATE) ELSE @DATE END Msg 241, Level 16, State 1, Line 2 Conversion failed when converting date and/or time from character string. Why is it trying to convert dasf to date when it clearly causes ISDATE(@DATE) = 1 to evaluate to false... If I do: SELECT ISDATE(@DATE) The return value is 0.

    Read the article

  • Learning Python else syntax error

    - by user1441016
    Hi I am learning python by doing the practice problems for Open course at MIT 6.00 Intro to Computer Science. I am Trying to do practice problem 1 part 2 create a recursive function to count the instance of key in target. My code so far... from string import * def countSubStringMatchRecursive (target, key,x,s): if (find(target,key)==find(target,key,s)) and (find(target,key)==find(target,key,(find(target,key)))):#if first and last return (1) elif (find(target,key)==find(target,key,s))and (find(target,key)!=find(target,key,(find(target,key)))):#if first but not last x=1 s= find(target,key) return (countSubStringMatchRecursive(target,key,s,x) elif (find(target,key,s))==-1 and (find(target,key)!=find(target,key,s)):#if last but not first return (x+1) elif:(find(target,key,s))!=-1 and (find(target,key)!=find(target,key,s)):#if not last and not first x=x+1 s= find(target,key,s) return (countSubStringMatchRecursive(target,key,s,x) I getting a syntax error at line 8. I would just like to know what I did wrong there. Dont worry about the other mistakes I should be able to get those sorted out. I just Stuck on this. Thanks.

    Read the article

  • What's wrong with my using pdo this way?

    - by user198729
    $sql = "SELECT * FROM table ORDER BY :sort :dir LIMIT :start, :results"; $stmt = $dbh->prepare($sql); $stmt->execute(array( 'sort' => $_GET['sort'], 'dir' => $_GET['dir'], 'start' => $_GET['start'], 'results' => $_GET['results'], ) ); I tried to use prepare to do the job,but $stmt->fetchAll(PDO::FETCH_ASSOC); returns nothing.

    Read the article

  • MySQL Query - WHERE and IF?

    - by Prash
    I'm not quite sure how to right this query. Basically, I'm going to have a table with two columns (OS and country_code) - more columns too, but those are the conditional ones. These will be either set to 0 for all, or specific ones, separated by commas. Now, what I'm trying achieve is pull data from the table if the OS and country_code = 0, or if they contain matching data (separated by commas). Then, I have a column for time. I want to select rows where the time is GREATER than the time column, unless the column time_t is set to false, in which case this shouldn't matter. I hope I explained it right? This is what I kind of have so far: $get = $db->prepare("SELECT * FROM commands WHERE country_code = 0 OR country_code LIKE :country_code AND OS = 0 OR OS LIKE :OS AND IF (time_t = 1, expiry > NOW()) "); $get->execute(array( ':country_code' => "%{$data['country_code']}%", ':OS' => "%{$data['OS']}%" ));

    Read the article

  • Refactoring if/else logic

    - by David
    I have a java class with a thousand line method of if/else logic like this: if (userType == "admin") { if (age > 12) { if (location == "USA") { // do stuff } else if (location == "Mexico") { // do something slightly different than the US case } } else if (age < 12 && age > 4) { if (location == "USA") { // do something slightly different than the age > 12 US case } else if (location == "Mexico") { // do something slightly different } } } else if (userType == "student") { if (age > 12) { if (location == "USA") { // do stuff } else if (location == "Mexico") { // do something slightly different than the US case } } else if (age < 12 && age > 4) { if (location == "USA") { // do something slightly different than the age > 12 US case } else if (location == "Mexico") { // do something slightly different } } How should I refactor this into something more managable?

    Read the article

  • Best index(es) to use for an OR Statement in SQL Server

    - by Chuck Haines
    I have a table which has a bunch of columns but the two relevant ones are: Due_Amount MONEY Bounced_Due_Amount MONEY I have a SQL query like the following SELECT * FROM table WHERE (Due_Amount 0 OR Bounced_Due_Amount 0) Would the best index to put on this table for SQL Server 2008 be an index which includes both columns in the index, or should I put an separate index on each column?

    Read the article

  • php multidimensional array if loop

    - by user1091558
    I have a multidimensional array like this array[value][1][1] Now i would like to implement if loop like this if ($value = array[value][1][1]) { echo "It works"; } Now it works if i assign the values like [1][1],[2][1]. Is it possible to compare the whole array. I mean if the array looks like array[value][1][1],array[value][2][1],..........,array[value][n][1] It works should be echoed. I tried like this. if ($value = array[value][][]) { echo "It works"; } But its not working. Can anyone give me the correct syntax?

    Read the article

  • Need help fetching an array using prepared statments

    - by eldan221
    I have wrote the following code to fetch a string. But for some reason its only returning 1. I have doubled checked everything and it seems like its correct. I am not sure why its only returning 1? Any help here would be really appreciated! //Class Defined here function MenuCat($id){ $query = "SELECT menu_category_description FROM menu_categories WHERE id = ?"; $stmt = $this->db->prepare($query); $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($menu_category_description); $row = $stmt->fetch(); return $row; } $display_category = $cat_des->MenuCat($id); echo $display_category

    Read the article

  • Prolem with if function

    - by Ryan
    Hi, something seems to be wrong with the first line of this if function, seems alright to me though. if ($count1 == sizeof($map) && $count2 == sizeof($map[0])){ echo ";"; }else{ echo ","; } This is the error I get (line 36 is the first line of the above line.) Parse error: parse error in C:\wamp\www\game\mapArrayConvertor.php on line 36 EDIT: The OP notes in an answer below that the error was a missing semi-colon on line 35 and not the code included in the question.

    Read the article

  • Simple php if query to double check

    - by skarama
    Is anything wrong with this code? <?php $variable = ; if (isset($variable)) { echo $variable ; echo "also this" ; } else echo "The variable is not set" ; ?> also, the other potential value of the variable is : $variable = <a href="http://www.mysite.com/article">This Article</a>; To clarify, I have a variable that may hold one of two possible values : an a href tag with it's url, or notihng at all. I need to have two different printouts for each of these cases, maybe I'm not doing it the right way though!

    Read the article

  • How to write a CASE WHEN statement with multiple DATEDIFF variables

    - by Anne C
    I need to calculate the difference between two dates (facility_start_date, facility_end_date) for a report in Reporting Services in SQL 2005. If the facility_end_date is null then it needs to use the report parameter @EndDate in the calculation. However if the facility_end_date is greater than the parameter @EndDate, then it also needs to use the paramenter @EndDate. The code below works fine except that if the facility_end_date is greater than the parameter @EndDate it is still calculating between the facility_start_date and facility_end_date, rather than between the facility_start_date and @EndDate. Any help would be appreciated. CASE WHEN facility_start_date > facility_end_date THEN NULL WHEN DATEPART(day , facility_start_date) > DATEPART(day , facility_end_date) THEN DATEDIFF(d , facility_start_date , ISNULL(facility_end_date , @EndDate)) - 1 WHEN DATEPART(day , .facility_end_date) > DATEPART(day , @EndDate) THEN DATEDIFF(d , facility_start_date , @EndDate) - 1 ELSE DATEDIFF(d , facility_start_date , ISNULL facility_end_date , @EndDate)) END

    Read the article

  • SQL update statement to change the value of a field and not replace it

    - by wzzrd
    I'm in the process of migrating some databases. I have this table that has a couple of hundred rows, and has a filename column. To each record in this table, the filename column needs to be altered and part of a path needs to be prepended to the value that is in that field. The table is like: | 1 | filename1 | | 2 | filename2 | and needs to become: | 1 | path/filename1 | | 2 | path/filename2 | I am not an SQL guru, but I know the basics. This eludes me though. Is there a way to do something like: update table set filename = 'path/' + filename where id = 1;

    Read the article

  • Help me construct this Linq statement

    - by Geoffrey
    There should be a simple Linq query for what I'm trying to accomplish, but I'm producing some ugly code. I have two tables, one of issues and another of issue status. There is a one-to-many relationship between issue and issue status. When an issue is created an IssueStatus is also created with the status field set to "Open" when it is closed, another IssueStatus is created with the status field set to "Closed" ... but issues can be re-opened. It seems like I should be able to write something like this: public static List<Issue> FindOpenIssues(this IList<Issue> issues) { return ( from issue in issues from issueStatus in issue.issueStatus.OrderBy(x=>x.CreatedOn).Single() where issueStatus.Status == "Open" select issue ).ToList(); } This obviously fails, but there must be a clean way to do this? Thanks!

    Read the article

  • Jump to the start of next statement

    - by Borek
    Say that I'm writing a test and my caret is here (indicated by "|"): [ExpectedException(typeof(InvalidOperationException|))] In Visual Studio 2010, I'd like to press some shortcut that would take me to the next line so that I could start typing "public void Etc()". Right now, I need to press Right arrow Right arrow Right arrow Enter Which is too many key presses IMO. Is there a VS2010 / ReSharper shortcut to aid this operation?

    Read the article

  • Generate switch cases in php from an array?

    - by mopsyd
    Is it possible to generate the cases for a switch in php using an array? Something like: $x=array( 0 => 'foo', 1 => 'bar', 2 => 'foobar' ); $y='foobar' switch($y) { foreach($x as $i) { case $x: print 'Variable $y tripped switch: '.$i.'<br>'; break; } } I would like to be able to pull the case values from a database and loop through them with a while() loop.

    Read the article

  • The best way to return related data in a SQL statement

    - by Darvis Lombardo
    I have a question on the best method to get back to a piece of data that is in a related table on the other side of a many-to-many relationship table. My first method uses joins to get back to the data, but because there are multiple matching rows in the relationship table, I had to use a TOP 1 to get a single row result. My second method uses a subquery to get the data but this just doesn't feel right. So, my question is, which is the preferred method, or is there a better method? The script needed to create the test tables, insert data, and run the two queries is below. Thanks for your advice! Darvis -------------------------------------------------------------------------------------------- -- Create Tables -------------------------------------------------------------------------------------------- DECLARE @TableA TABLE ( [A_ID] [int] IDENTITY(1,1) NOT NULL, [Description] [varchar](50) NULL) DECLARE @TableB TABLE ( [B_ID] [int] IDENTITY(1,1) NOT NULL, [A_ID] [int] NOT NULL, [Description] [varchar](50) NOT NULL) DECLARE @TableC TABLE ( [C_ID] [int] IDENTITY(1,1) NOT NULL, [Description] [varchar](50) NOT NULL) DECLARE @TableB_C TABLE ( [B_ID] [int] NOT NULL, [C_ID] [int] NOT NULL) -------------------------------------------------------------------------------------------- -- Insert Test Data -------------------------------------------------------------------------------------------- INSERT INTO @TableA VALUES('A-One') INSERT INTO @TableA VALUES('A-Two') INSERT INTO @TableA VALUES('A-Three') INSERT INTO @TableB (A_ID, Description) VALUES(1,'B-One') INSERT INTO @TableB (A_ID, Description) VALUES(1,'B-Two') INSERT INTO @TableB (A_ID, Description) VALUES(1,'B-Three') INSERT INTO @TableB (A_ID, Description) VALUES(2,'B-Four') INSERT INTO @TableB (A_ID, Description) VALUES(2,'B-Five') INSERT INTO @TableB (A_ID, Description) VALUES(3,'B-Six') INSERT INTO @TableC VALUES('C-One') INSERT INTO @TableC VALUES('C-Two') INSERT INTO @TableC VALUES('C-Three') INSERT INTO @TableB_C (B_ID, C_ID) VALUES(1, 1) INSERT INTO @TableB_C (B_ID, C_ID) VALUES(2, 1) INSERT INTO @TableB_C (B_ID, C_ID) VALUES(3, 1) -------------------------------------------------------------------------------------------- -- Get result - method 1 -------------------------------------------------------------------------------------------- SELECT TOP 1 C.*, A.Description FROM @TableC C JOIN @TableB_C BC ON BC.C_ID = C.C_ID JOIN @TableB B ON B.B_ID = BC.B_ID JOIN @TableA A ON B.A_ID = A.A_ID WHERE C.C_ID = 1 -------------------------------------------------------------------------------------------- -- Get result - method 2 -------------------------------------------------------------------------------------------- SELECT C.*, (SELECT A.Description FROM @TableA A WHERE EXISTS (SELECT * FROM @TableB_C BC JOIN @TableB B ON B.B_ID = BC.B_ID WHERE BC.C_ID = C.C_ID AND B.A_ID = A.A_ID)) FROM @TableC C WHERE C.C_ID = 1

    Read the article

< Previous Page | 39 40 41 42 43 44 45 46 47 48 49 50  | Next Page >