Hi there
well as a beginner, i would first like to apology of taking some of your valuable time.
i am looking to show some of elements at page depending on dropdown selection. also i would like the dropdown list to be based on database so instead of going to change it via "manage item"
Hi 3shtar,
so a few issue/questions with your code.
1. seem that you're missing a closing '}' at the end of the code snippet.
2. is your collection really named "collection"? you have to make sure to pass to the query() function the right name of your collection.
3. is the field you want to look for values in really named "field"? same comment as above.
4. checking for string equality (or any equality for that matter) should be done with the '===' operator. using '=' makes an assignment. so your code should be if (res === "AdjustmentLogo").
5. there's an extra '0' character in the then() line. needs to be removed.
hope it helps...
Dear Gents,
i had tried to copy the given code but it did not work
as my drop down selection has values {0=AdjustmentLogo,1=newLogo}
an uploadbutton should be enabled only if "res is AdjustmentLogo"
import wixData from 'wix-data'; export function selection1_onChange(event) { let value = $w("#selection1").value; wixData.query('collection') .eq('field',value) .find() .then(res => 0 { if (res = "AdjustmentLogo" ) $w("#uploadButton1").enable(); })
sorry for interrupting but hope to get some help :S
thank you
Hi,
we appreciate you asking questions, so feel free. It is to the benefit of the community. :)
Now as Andreas already pointed out you can use onChange event handler to handle the change in value and hide and show elements based on the new value. Most elements have .show() and .hide() methods for that purpose.
To populate the dropdown values form database, you can use a dataset. Add a Dataset selecting a collection that holds your options and then connect DropDown options to the dataset (it's in Connect a List section).
I hope this helps. Don't hesitate if you have any more questions. And have fun Wix Coding! :)
This is doable. Try searching this forum for Dropdown and you will find many other questions with answers already published.
import wixData from 'wix-data'; export function dropdown_onChange(event) { let value = $w('#dropdown').value; wixData.query('collection') .eq('field', value) .find() .then(res => { if (res.length > 0) // Use the setFiler on your other Data Collection here with the key value from res.fieldname that you want to filer on. }) }
You can also start by using a query and add the results to the dropdown in the page on ready event.
Hope to give you something to start with.