Results on click without Dropdown menu

Is there any way of creating a search by clicking on a word without it being in a dropdown menu? For example I would like to list ‘subject’ words from my database on a page and when some one clicks on a word, it displays the results on another page that contain that ‘subject’.

I can do it with a dropdown menu, I’m just wondering if there is a way of getting results without it being part of a dropdown menu. Mainly because there are too many options for a dropdown menu.

Hello beck_1001,

i think that i not really understood your problem, because i can not see your site-project, but what about a second DATABASE, which collects all the needed words?

The question is, how you want to list these words?
How it looks like your "word-listing-page?
How looks like your options?

To display some collected stuff on another page should be possible.

But can not really help, cause do not see what you can see :wink:

Hello Russian-dima

Thank you for your response.

I can list the words on the site, e.g. the database stores research articles, and it split into fields, title, date, subjects etc.

I want to give the user searching the option to browse by subjects, but there is too many to have in a dropdown menu. So I was going to manually list theme, e.g.

Cardiology
Dementia
ENT

and when some one clicks on the word, it links to a dynamic page with a repeater, giving the results of all the articles that contain that word in the subjects field.

Hello, then you will need something like that …
https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html#contains

Hi @beck_1001 , yes you can do it.

First, you’ll need to create an onClick() function for the button you want to search, here’s an example, a button labeled as “SAMSUNG”, you want to search the products collection for a SAMSUNG smartphone.

Let’s assume that your button ID is ( brandSamsung ):

$w('#brandSamsung').onClick( (event) => {
    wixData.query('products').eq('brand', 'samsung').find()
    .then( (searchResult) => {
        if (searchResult.items.length > 0) {
            // Show the results here
        } else {
            // Show a no result message
        }
    }).catch((err) => {
        console.warn("Search failed!");
        console.error(err);
    })
})

Learn more about WixDataQuery API.

If you want to show the results in a new page, please use the WixStorage API to know how you can pass the search term or anything to another page or lightbox.

Hope that helped!
Ahmad

thank you I will try these.

Hi Ahmad

Thank you very much for your response and the example.
I will give this a try, many thanks.

Beck