Customizing jQuery UI Autcomplete - jquery-ui

I want to make a few customizations to jQuery UI Autcomplete:
1) If there are no results found it should output "no results found" in the list.
2) Is it possible to highlight/bold the letters in the results as they are being typed? For example if I type "ball" and I have "football" in my results it needs to output as foot ball
3) Is it possible for the results that appear at the top to match the beginning of the string. For example suppose I have 3 entries in my database:
Astrologer
Space Station
Star
I start typing "st" - this will bring up those 3 entries in that order. But I want "Star" to be the first result.
The MySQL query being used at the moment to generate the results is:
$query = mysql_query("SELECT id, name FROM customer WHERE name LIKE '%".$_GET['term']."%' ORDER BY name");

You can simply echo 'No results found' inside the script that returns the list if num rows from your mysql_query is 0.
This was possible in the original Autocomplete plugin but I can't see it anywhere in the JQuery UI documentation.
You may have to run two separate mysql queries - the first one looking for LIKE '".$_GET['term']."%' and the second one as you have it, but excluding the results you've already got from the first query.

Related

Results of running two subqueries do not add up to the number of results when running the main query

I am running a JQL query to count how many issues have an empty value for the "Components" field versus how many issues have a non empty value for the "Components" field.
Here is the screenshot that I get for my 1st JQL query: category = "Cloud Services" and component is empty, the number of results is 6631:
Checking for null is equivalent to checling for empty, I have tried it and it returns the same.
Here is the screenshot for my 2nd JQL query: category = "Cloud Services" and component is not empty
The thing that confuses me is that I get 6631 results for my first query and I get 51372 results for my second result so 51372 +6631 = 58003
However, when I try to retrieve all the issues belonging to the Cloud Services category with this query: category = "Cloud Services", I get the following: I get 64879 as a result which does not match 51372 +6631 = 58003 computed above. Anyone knows why? Normally, the total number should correspond to the result of the 3rd screenshot since every issue contains components.
this only means, you have in the project more than 1 component, that is why the adds dont match.
with the REST api you can verify howmany and which components you have:
https://<host>/rest/api/latest/project/<project_id>/components
Could also be that one of the projects has a field configuration with the Components field hidden?

SELECT statement with multiple conditions on TAGs

For considerably long period of time I’ve been struggling the following problem. This is an example of data stored in the DB:
> show series
flights,cycleId=1535,cycleIdx=0,engineId=2,flightId=1696,flightIdx=0,type=fil
flights,cycleId=1535,cycleIdx=0,engineId=2,flightId=1696,flightIdx=0,type=std
flights,cycleId=1535,cycleIdx=0,engineId=2,flightId=1696,flightIdx=0,type=raw
...
and my intention is to select a specific one by using a query like this:
SELECT * FROM flights WHERE type='fil' AND engineId= '2' AND flightId = '1696' AND flightIdx = '0' AND cycleId = '1535' AND cycleIdx = '0'
Such query, however, yields always zero results. Zilch.
Selecting the first (and only) tag works fine:
SELECT * FROM flights WHERE cycleId = '1535'
but using this condition on any other tag, like for example
SELECT * FROM flights WHERE type='fil'
does never return a single row. Querying only the first tag and nothing else works.
Could you please give me a hint what am I doing wrong? From all I have found people are always selecting just by a single tag but never more. What is the part that I cannot see?
Many thanks for any ideas!
I believe I have discovered the reason: two keys from the tags made by mistake their way into the fields. I spotted the trouble when listing the tag and fields keys as
show tag keys
show field keys
Deleting all records does not remove the keys from these lists and the problem persists. One need to drop the entire database to restore the order of things.

How to count instances of text

I have a list of email addresses in SPSS. I'm trying to write syntax to count how many times each email address appears.
For instance:
In my desired output, if johndoe#aol.com appears in the data 3 times, I want all instances of his email to show a 3 in my new column.
I know I can write syntax to have it count (ie johndoe#aol.com will be assigned 1 the first time, then 2 then 3)... but this is not what I want.
Thanks!
Steps to do this:
Sort cases by email.
Get the counts using the Aggregate command.
Use the Identify Duplicate Cases command to generate an indicator of whether a given email is the first of its kind in the file.
Select cases that aren't the first with that particular email.
All four of those commands are in the Data menu in the GUI. Syntax to do the whole thing:
SORT CASES BY Email.
*This will create a new variable N_EMAIL with the counts. It will appear for every case.
AGGREGATE
/OUTFILE=* MODE=ADDVARIABLES
/PRESORTED
/BREAK=Email
/N_EMAIL=N.
*Now we generate a "PrimaryFirst" indicator showing whether a given case is the first instance of its email.
MATCH FILES
/FILE=*
/BY Email
/FIRST=PrimaryFirst
/LAST=PrimaryLast.
DO IF (PrimaryFirst).
COMPUTE MatchSequence=1-PrimaryLast.
ELSE.
COMPUTE MatchSequence=MatchSequence+1.
END IF.
LEAVE MatchSequence.
FORMATS MatchSequence (f7).
COMPUTE InDupGrp=MatchSequence>0.
SORT CASES InDupGrp(D).
MATCH FILES
/FILE=*
/DROP=PrimaryLast InDupGrp MatchSequence.
EXECUTE.
*Filter out duplicate cases.
SELECT IF PrimaryFirst = 1.
EXECUTE.
*Final cleanup.
DELETE VARIABLES PrimaryFirst.
Just run this:
AGGREGATE /OUTFILE=* MODE=ADDVARIABLES /BREAK=EmailAddress /num_instances=N.
A new column will appear in the dataset called num_instances (you can of course select another name) which will have the desired count appear in all instances of each Email address.

App Inventor Fusion Table Column calling

I developed an app based on App Inventor and Fusion Tables. When I want to update total money by adding some money to already existing money it is giving some error.
When I use SELECT command to get information from fusion table it is taking then number with column Name. When i am trying to add both of them it is giving following error.
Error message
The result from a fusiontable includes always the header row...
from your example SELECT statement the result is
TotalPaid
5000
Obviously to add any value to that result will result in an error, because you only can add numeric values...
You first have to extract the value (in your example 5000) from the result. Convert the result into a list using the split block, just split at \n (new value) to get a list, then select the 2nd item using the select list item block.
Note: to be able to update something in a table, you need the ROWID, see also the SQL Reference Documentation of the Fusion Tables API.
For UPDATE statements the first step to be done is to get the ROWID of the row to be updated with a SELECT statement. The second step is to do the UPDATE.

Orbeon - how to set values of numerous fields with one query

I have created a database service that retrieves numerous columns. I have successfully created the action to call other queries which passes in a parameter and displays the output in drop-down box or check boxes. HOWEVER, with this new query I would like to set the values of 5 different fields on the form based on the single query call. What xpath expression syntax is needed in the 'Set Response Control Values' section in order to make this work.....or is this not the right place or way to do this?
Sounds like you're using Form Builder - in the "Set Response Control Values" section in the Actions Editor, you should set up one item for each form field to be updated, with the Destination Control drop-down specifying the form field. So in your case you'll have 5 rows pointing to your 5 fields.
Let's assume that your query returns a single row, with the values that will go into your form fields in separate columns. Your query results come from the database service looking like this:
<response>
<row>
<query-column-1>value</query-column-1>
<query-column-2>value</query-column-2>
...
</row>
</response>
So if the column name for your first item is "id", the "Set Response Control Values" entry would look like this:
/response/row/id
There is one gotcha...if a column name in the database includes an underscore, this will be converted to a hyphen in the results from the database service. So if your column name was "asset_id" you'd put response/row/asset-id.
If your query returns multiple rows, you can refer to a specific row using a predicate, like so: response/row[1]/id

Resources