Control how members view website in real time

I want to enable real-time member interactivity on my website. So I want to show members items from my dataset. But I want to have a button which is only visible to me so that I can click on it and move to the next item and the members on the site also can see the next item.

Basically I want to control the item view on my website. The members should only be able to see that and interact with that item only. When they refresh the page (accidentally or otherwise), it should show the current item which is visible to all the members.

Is this possible, please help.

Hello Ayush Awasthi,

yes i would say, it is possible.
For example you have a database-A where you have write-permissions and the users only read-permissions. Before I start writing a novel, here take a look at this example here, it might help you…

https://russian-dima.wixsite.com/meinewebsite/switch-safe-function

Well the site is under construction, but i will put an example-code here:

import wixData from 'wix-data';

//------------------------------------ USER-DATA-INTERFACE -----------------------------------------
//var DATABASE =    "Switch-Save-Function"
var DATASET =   "dataset1"
//------------------------------------ USER-DATA-INTERFACE -----------------------------------------
var currentItemIndex

$w.onReady(function () {
    $w("#"+DATASET).onReady( () => {
        $w('#TXTmember').text="Member-"+currentItemIndex
        $w('#BTNsave').onClick(()=>{
 if ($w('#BTNswitch1').checked===true){$w("#"+DATASET).setFieldValue("btnStatus", true);}
 else {$w("#"+DATASET).setFieldValue("btnStatus", false);}
            $w("#"+DATASET).save();
        })

        $w('#BTNnext').onClick(()=>{console.log("NEXT")
            currentItemIndex = $w("#"+DATASET).getCurrentItemIndex()+1
            console.log(currentItemIndex)
            $w('#TXTmember').text="Member-"+currentItemIndex
        })

        $w('#BTNprevious').onClick(()=>{console.log("PREVIOUS")
            currentItemIndex = $w("#"+DATASET).getCurrentItemIndex()+1
            console.log(currentItemIndex)
            $w('#TXTmember').text="Member-"+currentItemIndex
        })
    })
});

This example shows, how you could save data in your database. So if a user accidently REFRESH his site, the saved data will be still available.

I am not sure if I got this. What I am actually doing is I’m showing the user questions and keeping track of its answers. Then I have a next button, which then shows the next question. I want that when I click on that button, the user also sees the next question and then she can answer accordingly.

Ok, look.
Like you can switch Member in my example, you could also switch your QUESTIONS (Previous/Next), then you replace the SWITCH-Button witch a normal SAVE-Button.

So how it would work for you?
You have a lot of questions in your DATABASE. You could then switch with NEXT and PREVIOUS-button all your questions (stored in your database), and with a press on SAVE or CONFIRM, the choosen, question would get active and would be shown to all other USER.

Only if you would confirm your QUESTION-CHOICE, the question would appear for all USER.

Of course you would have to modify the CODE to your needs, but it has a similar principle, like that what you want to do.

The USERS would go to this page, where you show your questions in a LIGHTBOX, SLIDER-GALLARY, REPEATER or just in a normal BOX, MULTISTATE-BOX or STRIPE or what ever.

There are so many options. You could also play with the visibility of the elements…

https://russian-dima.wixsite.com/meinewebsite/working-with-buttons

I do not give you a suitable solution, i just give you ideas, how your solution could look like :wink:

As far as I can understand you are saving the state of the button in the database. But in my case, I have to show the same question to all my users.

When I refresh your website, although the state remains the same, but the page reloads to member-undefined.

I have figured out the boxes and all the other stuff. Just struggling with syncing data with all the users at the same time.

When I refresh your website, although the state remains the same, but the page reloads to member-undefined.

The STATE remains the same —> RIGHT (aktive Question will remain the same) The same question will be loaded at the page.

  1. User-A enter the page, what does he see? Of course the last activated question, because when this page loads (a database-query starts and looks for the last activated question.) last activated question found? Yes! And load it onto the stage, to show this last activated question to all the USER who enters the page.

Why all USER?
Because everytime when a user enters the QUESTIONPAGE, a query-funktion starts, fired by onReady-command.

So what do EVERY USER see, when he enters the page?
YES, the last activated QUESTION.

That is how i would solve this issue. :laughing:

EDIT:


You have just to expand and modify the given CODE a llittle bit.