Posts by nunks • 2,268 points
65 posts
-
1
votes2
answers863
viewsA: Swap image by clicking it (JS, jquery)
Having the URL of the new image, you just need to select the element <img> to be changed and to change the attribute src from it. In the example below I chose two Urls and used pure Javascript…
-
0
votes3
answers127
views -
3
votes2
answers240
viewsA: Concatenate items into a vector
The return you get from the database is a string that represents the syntax of a Python list, not a list itself. To use it as a list, you need Python to interpret the chunk of code it represents,…
-
0
votes1
answer876
viewsA: Calculate Quantity x Price and play value in input and session
You can use PHP itself in each unit value update and amount to persist the total in the session, saving even the extra AJAX call to the total value_value, since it changes whenever one of the other…
-
2
votes2
answers55
viewsA: Make an array for a query with false conditions
Beyond the elements key and value, to meta_query supports the comparison operator in the element compare. Try !=: $meta_query[] = array( 'key' => '_featured', 'value' => 'yes' , 'compare'…
-
2
votes1
answer112
viewsA: Return regular expression value
No need to specify the entire line in the expression if you want the value of "kts", the expression ([0-9]+) kts (one or more consecutive numbers of " kts") is enough for that line. In PHP use the…
-
0
votes1
answer1217
viewsA: Fire event by clicking outside element
With pure Javascript you can use addEventListener in the document and test whether the element DIV in question is or is not in the event propagation array. I took the liberty of leaving yours DIV…
-
1
votes2
answers135
viewsA: Error comparing PHP-Mysql dates
There is a problem in your definition of variables $dataInicio and $dataFim. Ternary operator returns '2017-09-25' and date("Y-m-d") case exists data in item $_POST correspondent. I imagine what you…
-
4
votes4
answers129
viewsA: Build database
In Postgresql you can use the function random() to simulate such data without the need for an external language, only with SQL. I imagine it’s something easily transportable to other database…
-
1
votes3
answers2181
views -
2
votes2
answers257
viewsA: break date in 3 columns in a mysql query
If I understand correctly, you want to break the date in columns to facilitate the consultation by month? Instead you can convert your date string into Mysql date using STR_TO_DATE and compare…
-
0
votes1
answer101
viewsA: How to sort the results more similar to the parameter passed?
To sort this array you need a similarity index that tells you that Guarulhos is the "best answer" of the three, something that has to be returned by the server that told you these are the most…
-
3
votes1
answer1874
viewsA: Scheduling System by Date
In the absence of a date/timestamp serial generator (I couldn’t find this feature in the Mysql documentation), I would create a table with the possible time range (from 9am to 5pm, for example), one…
-
0
votes2
answers41
viewsA: Javascript Json
For "code golfing" purposes:D let arrayDoServer = ["a: 0", "b: 1", "c: 0", "d: 0"]; let jsonDeSaida = JSON.parse('{"' + arrayDoServer.join('","').replace(/: /g, '":"') + '"}');…
javascriptanswered nunks 2,268 -
9
votes4
answers453
viewsA: Table change constraint with subquery
The only data closest to an explanation provided in own documentation is that the change works if the record comes from a "derived" table, as in the example below, and that this is due to the fact…