Update a Collection Item's Field

Hi everyone,

I hope this posts finds you well,

I have been trying to overcome an obstacle I found while working on my website. I appreciate any help I can get.

I want to update the field “rank” with the current value for “#input5 in my alloperations collection, which is connected to my #dynamicDataset every time the page is loaded.

This is my current code that relates to this issue:

 $w.onReady(() => {
 	$w("#dynamicDataset").onReady(() => {
 		$w("#dynamicDataset").setFieldValue("rank", $w("#input5").value);
 		$w("#dynamicDataset").save();
 	});
 });

I am using the SetFieldValue then save method, I have also tried the update method with no luck so far.

  • My database collection alloperations is open to anyone to update.
  • I have been continuously refreshing my live database.

I attach a picture of my database

I appreciate any help I can get,

Sincerely,

Nicolas

Hi Nicolas,

Do you have your dataset set for Read/Write? If it’s set to Read-only you won’t be able to save.


Good luck,

Yisrael

1 Like

Hi Yisrael,

Thanks for your help!

I made the change you suggested and added some timeouts, I tried without the time outs and it did not work properly.

I leave my code here if anyone is looking for/having the same issue.

Note: Really like the changes that were made on the Wix Code Editor, amazing work as always!

$w.onReady( () => {
  $w("#dynamicDataset").onReady( () => {
      setTimeout(() => {
    $w("#dynamicDataset").setFieldValue("rank", $w("#input5").value);
    $w("#dynamicDataset").save();
    }, 3000);

    });
 
    });

Thanks again Yisrael!

1 Like

Just for reference: Give the TextInput onKeyPress Function some time

1 Like

Thanks Again Yisrael!