Images not selecting

Hi,
I have some images that should update to the selected row in database. I have texts and tables also and when the query returns they show correctly ( cell shown is the right one ) but it is not working for the images as only the 1st row is returned.
I have set dataset to read & write as there are some user input. Everything works fine except images. Do not understand why or are images properties working in a different way? I have tried selecting or not quite everything and still the same.
I do not work on a dynamic page but I do not think it will change anything and it should not be as it is a very simple query and code.
Can anyone explain how to workround, even the basics of images?

Could you please explain in a little more detail what you are trying to do and what doesn’t work.

Please post the editor URL of your site. Only authorized Wix personnel can get access to your site in the editor. Please include the name of the page involved.

Hello Yisrael,

and thanks for answering me.
Ok I try to have visitor enter their birthdate in 1 one user input called ‘Year’ with ‘Année’ on the placeholder text.
Then on click it searches the year and shows on a table 2 different options - I then place a radiobutton on top of this table with no background ( like this we can visualise the texts option of the table ) that allows for selection of 1 option
Then on click, it shows another table that indicates the corrective ‘feng shui’ element for that year. The table has 2 columns: text: ( the corrected element … ) + text element ( aka: wood, metal, water, fire or earth ).
I would like at this 3rd point to have the 2 images under appear with 1 of them being the correct picture of the selected element bracelet ( red, black, white, brown or green ) and the other being a picture with the text legend of that bracelet.
Everything work fine ( the first user input being an exception as it should read ‘Année’ but it shows the 1st row of the year column of the database. Annoying but small problem and it appeared when I did change the dataset from write only to write and read.
Images are not behaving correctly. When I connect them they always return the value of the 1st row of the database ( aka 1919 ). But the last table returns the right values and it is connected the same way than the images. I do not understand why and if there is a difference working with image? I had already that problem before and had to design the site differently ( plain bull ).
Hope, that was not too long.
Best regard and best wishes for 2019,

Thierry

sorry, the page involved is called : feng shui?

You are doing a query and setting the contents of the table to the result. However, you have the image links connected to a dataset, but you never apply the appropriate filter to the dataset.

Keep in mind that a dataset is only a connector to the collection. Doing a query on a collection does not change the dataset. You need to do a setFilter() on the dataset to set the dataset to the correct items.

I would suggest removing the connection of the image to the database, and set the Image.src property to the image field in the results of the query. Something like:

export function searchButton_onClick(event) {
  wixData.query('Datelements')
    .contains('title', $w('#input1').value)
    .find()
    .then(res => {
       let items = res.items;
       let item = items[0];
       $w('#image8').src = item.couleur;
       $w('#table2').rows = res.items;
       $w('#button1').collapse();
       $w('#input1').collapse();
       $w("#table2").expand();
       $w('#input6').expand();
       $w('#radioGroup1').expand();
       $w('#button25').expand();
    });
}

The lines I added are in bold.

You can do the same thing for the other image that you want to set.

I just realized that the lines of code that I added should be in searchButton25_onClick() . I tried that and it seems to work - but I’m not sure what exactly it’s supposed to do.

Hi Ysrael,

just to let you know : it works perfectly and you have all my thanks - terrific job. And for your question: it was supposed to select the correct picture of the model of bracelet corresponding to the birthdate element of the user.
Best regards,

Thierry

Yay! I’m glad we were able to put it all together.

Hello Yisrael,

I am terribly confused to contact you again but I have a slight problem that I can not resolve.
As you can see in the picture sent earlier, I have 2 buttons where I have written on the placeholder the word :‘Année’ and selected Text on placeholder in settings. But since I have changed the code with your solution ( excellent however ), when started the 1st button always shows the 1st cell in the ‘year’ column no matter what I select in the settings of that button ( #input1 ) like : none, initial text, initial text than placeholder…
Ok, it is not the end of the world but it is annoying as the user has to erase the shown date before he can input the new one but before that just clicking on that button was clearing the text of the button making it ready for input.
Can you have a look at it - pleas…
Best regards,

Thierry

ok, I have found a workaround quite simple. I let the 1st row of my database empty and voila.

That’s great! But you’re right in calling it a workaround. I’ll try to look at it if I get a chance.

@yisrael-wix It is ok Yisrael, it works and I am not showing the code to the users so use your time for others but thanks for the offer. Otherwise, I have a very last problem that I can not resolve because I do not know how to approach it. Would it be ok if I send it to you directly ( as you know the site code ) or would you prefer that I post it on the forum?
Best regards,

Thierry