if-statement

pugjs able to use ternary for text?

冷暖自知 提交于 2020-01-23 20:24:21
问题 I know we are able to use ternary for attr but I am wondering if we can do it with plain text? let's say I have something like this button.btn.btn-round.btn-info | if image | Change Image else | Add Image the button will have the text either Change Image or Add image if image variable exists Is this possible to use ternary? Thanks in advance for any help and suggestions 回答1: Yes, it's absolutely possible. Just use the equals sign at the end of the element definition to get pug to evaluate

Mysql Update with if statement

为君一笑 提交于 2020-01-23 17:36:33
问题 In MySQL Table1 columns Id, Foo, Bar, Choc, Blk, AB Table2 columns ID, A, B, C Im trying to update table 1 col AB with result of IF( (C / ((A + B)/ 2))>1, "A...", "B..." ) from Table2 Where T1.id =t2.id 回答1: UPDATE table1 JOIN Table2 on Table1.id = Table2.id SET AB = CASE WHEN C / ((A + B)/ 2) > 1 THEN "A..." ELSE "B..." END 来源: https://stackoverflow.com/questions/5546067/mysql-update-with-if-statement

Change <select> options with javascript dynamically

荒凉一梦 提交于 2020-01-23 08:39:07
问题 Can I use a javascript if/else function to change the select options of a form? I don't want to use CSS to hide/display different dropdown menus, so here is what I've ccome up with: function getType() { var x = document.getElementById("food").value; var items; if (x === "fruit") { items = "Apple" || items = "Oranges" || items = "Bananas"; else { items = "Eggplants" || items = "Olives" } document.getElementById("pickone").value; } <input type="text" id="food"> <select id="pickone"> <option id=

How to detect if input is quote?

♀尐吖头ヾ 提交于 2020-01-23 02:03:30
问题 I have the following code if "%userInput%"==""" ( do_something ) I would like it to detect if the %userInput% is a quote( " ). However, this code throws an error. How to detect if input is a quote? 回答1: Here is a solution without delayed expansion that should work with any input, including spaces and poison characters. My test code is in a loop. When you are ready to quit, simply press <Enter> without typing anything. @echo off setlocal :loop set "var=" set /p "var=enter a string: " if not

powershell if-else does not follow either branch

泪湿孤枕 提交于 2020-01-23 01:58:31
问题 I have the powershell code $target_dir = "\\server\share\" $DelTmpStatus = "init value" if ( Test-Path ( $target_dir + "receivals.tmp") ) { del ( $target_dir + "receivals.tmp") $DelTmpStatus = "Present and delete status $?" } else { $DelTmpStatus = "NA" } and sometimes it makes it through this section with $DelTmpStatus still set to "init value". How can the if-else structure not follow either path? Does the if-else structure in powershell not do anything when the if function is given an

PHP/HTML/CSS - If FireFox, If Chrome, If Safari

天涯浪子 提交于 2020-01-22 07:36:51
问题 Is there a simple conditional statement, css command, html, jquery, javascript or simple PHP dynamic way of detecting the current browser? <!if firefox> .element { top:4px; } <![endif]> <!if chrome> .element { top:6px; } <![endif]> <!if ie> .element { top:8px; } <![endif]> <!if opera> .element { top:10px; } <![endif]> <!if safari_webkit> .element { top:12px; } <![endif]> Can this Psuedo code be done in jQuery/JS/HTML or CSS PHP etc? 回答1: With CSS there is no way you can achieve browser

Dividing a matrix into two parts

僤鯓⒐⒋嵵緔 提交于 2020-01-22 02:56:08
问题 I am trying to classify my dataset. To do this, I will use the 4th column of my dataset. If the 4th column of the dataset is equal to 1, that row will added in new matrix called Q1 . If the 4th column of the dataset is equal to 2, that row will be added to matrix Q2 . My code: i = input('Enter a start row: '); j = input('Enter a end row: '); search = importfiledataset('search-queries-features.csv',i,j); [n, p] = size(search); if j>n disp('Please enter a smaller number!'); end for s = i:j

Bash Multiple Conditions in If Statement and Functions

我怕爱的太早我们不能终老 提交于 2020-01-22 02:39:08
问题 I'm trying to check if the number of arguments is one and if functions that I wrote in my script previously are true , but it does not work: if [ $# -eq 1 && echo "$1" | lgt && echo "Invalid Length - $1" && echo "$1" | checking_another_function_etc ]; then echo "some output" && exit 1 "lgt" is a function name. I was trying to use (( [[ [ quotes, multiple if statements but it didn't work either. Maybe I should separate the number of arguments checking and functions with quotes, but I'm not

IF statement with logical OR [duplicate]

北城余情 提交于 2020-01-22 02:22:07
问题 This question already has answers here : Can you use 2 or more OR conditions in an if statement? (6 answers) Closed 2 years ago . if(1 == 2 || 4) { cout<<"True"; } else { cout<<"False"; } This is how I read the above. If 1 is equal to 2 or 4, then print true. Otherwise, print false. When this is executed though... true is printed. Obviously I'm misunderstanding something here. 1 is not equal to 2 or 4. Wouldn't that make it false? 回答1: Yeah, I've made the same mistake. Read the sentence again

Simply check for multiple statements C#

倖福魔咒の 提交于 2020-01-21 23:54:08
问题 Currently working on a small console game and was wondering if anyone has a simple way to shorten something like this: if (map[playerX - 1, playerY] == "R1" || map[playerX - 1, playerY] == "R2" || map[playerX - 1, playerY] == "R3" || map[playerX - 1, playerY] == "Z1" || map[playerX - 1, playerY] == "Z2" || map[playerX - 1, playerY] == "Z3" || map[playerX - 1, playerY] == "S1 " || map[playerX - 1, playerY] == "S2" || map[playerX - 1, playerY] == "S3") making a list or something and checking if