if-statement

Javascript return false in if statements

Hey all, Is it good practice to use "return false;" to basically say do nothing in an if statement? For example: if (navigator.userAgent.match(/iPad/i) != null) { return false; } else { //Usual script here } just wondering if there are any downfalls to this. I can use the if statement without the else but i'm just wanting to ...

Determine if all checkboxes within jQuery object are checked, return as boolean

Hey all. I've been been trying to figure this out for a while now. I create a jQuery object of checkboxes and store it in a variable: $group1 = $('#checkbox1,#checkbox2,#checkbox3,#checkbox4'); The user cannot continue unless all checkboxes in that group are checked. I've been using an if statement combined with .is(':checked') to f...

Ruby if oneliner inside if statement yields error

Here's an unexpected find. Something of a very basic Ruby issue that I haven't happened to run into before: a = "a" if a test = "yes" if a == "a" else "no" else test = "no" end Running this yields the error: syntax error, unexpected kELSE, expecting kEND Looks like the nested oneliner spills out into the enclosing if statement...

IF Not taking any decision?

Look at this: foreach(Object Item in comboBox1.Items) { if (Convert.ToString(Item) == Convert.ToString(dsGirasol.Tables["DatosGirasol"].Rows[contador][0])) { repetido = true; break; } else { repetido = false; } }​ Note that both of the possible outputs have a messagebox. However when I ...

Why won't my simple if statement work?

Hello! I've designed a simple card game where two cards are displayed and the user has to bet on whether they will get a card that is inbetween the two cards displayed. If the user doesn't want to bet, they just deal again. The user begins with £100. The game works fine in most aspects, but has a huge flaw. The user can bet more than the...

javascript drop down loop if statement

I have created 2 drop down menus, from and to, these include times starting from 8 > 22:00, however on submitting the form it is asking me to select a start time which has already been selected and confirmed by an alert option i have included, has really confused me!! any help appreciated. craig window.status='Loading contingency scrip...

javascript drop down loop if statement

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

What would be a better way to code this if then else clause?

I have the following code. I'm still a newbie in Ruby on Rails. As you can see I'm repeating myself 4 times. I tried something like this: if @property.nil? || @property.status_id == 144 || (@property.status_id <= 16 && current_user.nil?) || (@property.status_id <= 16 && current_user.id != @property.user_id) But it gives me lots of e...

Python runs a if-case that it should not!

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

ModalPopUpExtender not showing up within a 'if' statement

Here is my code: .modalBackground { background-color:Gray; filter:alpha(opacity = 70); opacity:0.7; } .panelStyle { background-color:White; width:400px; height:370px; } .okbtn { width:60px; margin-top:5px; text-align:left; } .clo...

jQuery ELSE IF - textfield registers click as "not empty" and ignores alert

my statements and code work well, ALTHOUGH if i click in either textfield and don't enter a value the jQuery registers it as "not empty" in the field and does not execute the alert. What do you think i've missed? or need to add? I'm working in a Groovy/Grails environment, hence my g: fields. // if textfield has or has no content show...

how to use a nested if and perform correct file checks in unix

Need some shell scripting help, especially with my if-then-else logic. I want to combine both conditions, but not sure if the file checks will work the same? Should I be doing something like a nested if?? My script uses the if statements to do file checks to see if they exist, then do something.. There is probably a better way to do fi...

pythonic way to rewrite an assignment in an if statement

Is there a pythonic preferred way to do this that I would do in C++: for s in str: if r = regex.match(s): print r.groups() I really like that syntax, imo it's a lot cleaner than having temporary variables everywhere. The only other way that's not overly complex is for s in str: r = regex.match(s) if r: p...

MySQL - conditional SELECT

I have tables item and store (it's a store management system). item table has a column called store_id and another column called status. item.status can be 'sold' or 'unsold'. I need help writing a query which will do these things: select all items of all stores if a store has just one item and that item is 'sold', remove that item fr...

Access VBA: If Form Value <> NULL then run query else, end if. - not doing anything

Hi guys, I have a piece of code that I've haphazardly written in order to run a query on_click of a form button. Private Sub Command153_Click() If Forms![form name1]![form name2]!Text143 <> Null Then DoCmd.OpenQuery "InsertGroup", acNormal, acEdit Else End If End Sub I haven't written a custom if before in VBA so I think I'm probably ...

Unordered List size scroll question

I have an UL with a lot of List items in it, I made a custom scroll to animate the DIV box so that you can see all the list items, i was the make an if else statement that says if your at the top you cant scroll past it and if you dont need to scroll to see anymore LI you cant go down any further. ...

Optimizing nested if/ then, java

This code's only redeeming quality is that it works. Can you please help me structure it better? if (profile.isIgnoreCase()) { // ignore case if (masterKey.equalsIgnoreCase((targetKey))) { if (masterValue.equalsIgnoreCase(targetValue)) { doOK(masterKey, masterValue); break; } else { // Key is eith...

How to use if condition inside string in php

Hi, I want to know if there is a way to use something like this: $t1=1; $t2=2; $t3="$t1>$t2"; if($t3) echo "Greater"; else echo "Smaller"; This will evaluate to true as $t3 is a string, but that's wrong!!! So is there a way to include the if condition inside string. I heard that we can use eval for this: http://stackoverflow....

jQuery Watermark and using .Val()

Hi Guys, I have a problem in that I am using a simple watermark plugin such that it works jQuery('#selector').Watermark('Watermark text here ...'); The problem is - when I try and use something like if (jQuery('#selector').val() != "") { //do stuff } The statement is True because of the watermark. Is there anyway I can somehow "ig...

PHP IF Statement executing both conditions

Hi, I'm currently integrating a payment system into my website. I have a response script which basically takes in the data from the secure server and displays to the customer if the payment has gone through or not. My problem is that the if statement is actually displaying both messages to the customer, even if the payment has been suc...