Displaying and hiding active button

I fixed it and it work

now i need your help in this
console does not show any error at all
so i have two column in my dataset one contractavailable (0 or 1) and a contracts that i have attached contract document to it.
what’s wrong with this code
$w ( “#repeater3” ). onItemReady (( $contract , contract , index ) => {
if ( contract . contractAvailable == 1 ) {
$w ( ‘#contract’ ). show ();
}
else {
$w ( ‘#contract’ ). hide ();
}
});

Everything is wrong → because of your leck of basic-knowledge.
Totaly wrong part here…

$w("#repeater3").onItemReady(($contract,contract,index)=>{

I did not gave you this code-lines!

Please take a look into the “Velo-API-Documentations”…

thank you for your kindness however that’s what made active and inactive button worked
$w . onReady (() => {

$w ( “#repeater3” ). onItemReady (( $active , active , index ) => {

if ( active . active === active ) {
$w ( ‘#active’ ). show ( ‘Active’ );
}
else {
$w ( ‘#active’ ). show ( ‘Dormant’ );
}
});

i will try to figure myself. my last coding job was 25 years ago.

Just a last tip → change back to " itemData " instead of “active”.
And perhaps also → back form “$active” → to → " $item "

Your variables should be declared clearly, logical and plausible!

But it is on your decision.

hold on you cannot leave now. I need your help to finish this one. I know Ninja do not leave till they got their job done

@nhbarakat
:rofl:you are right, but!

→ JOBS are payed! :wink:

All i do is helping you 4-free.

But if you have further questions on your topic, you can ask , no problem.

You are right. You are helping me for free. So why do not we schedule a zoom call and help me. If you do not mind I can pay you by zelle, credit card or by a check
what do you think?

There are a lot of possibilities, where you can find website-developer coder & designer, for example…

-Wix-Marketplace
-Fiverr
-Freelancer

But you can also send me an email if you want. I am always open for NEW projects.

Email can be found in my profile.

ok this is my code
import wixUsers from ‘wix-users’ ;
import wixData from ‘wix-data’ ;
let $item = ‘active’ ;
let itemdata = ‘active’ ;
let $item1 = ‘contract’ ;
let itemdata1 = ‘contract’ ;
$w . onReady (() => {

$w ( “#repeater3” ). onItemReady (( $item , itemdata , index ) => {

if ( itemdata . active === ‘active’ ) {
$w ( ‘#actives’ ). show ( ‘Active’ );
$w ( “#button1” ). style . backgroundColor = “rgb(255, 0, 0)” ;
}
else {
$w ( ‘#actives’ ). show ( ‘Dormant’ );
$w ( “#button1” ). style . backgroundColor = “rgb(0, 0, 255)” ;
}
});
$w ( “#repeater3” ). onItemReady (( $item1 , itemdata1 , index ) => {

if ( itemdata1 . contract === ‘Active’ ) {
$w ( ‘#signcontract’ ). show ();
}
else {
$w ( ‘#signcontract’ ). hide ();
}
});
});
i am having issue with button showing red when i need to and showing blue when i need to
what i am doing wrong here

You have 2x onItemReady!
Use just 1x

ok is there any other way to do it beside this. as i need to check if it is active or inactive and i need to check if there is a contract
the result are
if it is active show active with red button
if it is dormant show dormant with blue button
if there is a contract show contract
if there is no contract show nothing

It is absolutely not clear how is settep-up your DATABASE.
Everythings depends on the structure of your DATABASE.

databse

This is exactly what i expected!

Look onto your DESCRIPTION one more time…

I have a dataset (site content permissions) named contractors list. I have a page (contractor List) that display all content in this dataset name and done by repeater. On this repeater I have a button that show if contractor is active and name active. In the dataset I have ActiveStatus element that is Boolean based on true or false . so when activeStatus is true than active button is displayed otherwise is hidde. this is my code
I can’t find any → Boolean ← value in your DATABASE.

-Datafield → “active” → STRING/TEXT
-Datafield → “contract” → STRING/TEXT

You have → “Active” & “Dormant”
If i would be you → i would use → " active " & " inactive " ← more logical
And my DATAFIELD-Name would be —> " Activity " (ID = " activity ") <–plausible

And if you want to do it even better & more efficient, you would use → BOOLEAN
Like you were describing it in your project-description.


You can do the same for → “contract” and also can use → BOOLEAN , if you have just 2x-different states —> " active " & " inactive "

Than it would look like this one…


Your code for the last showed DB-example, could look like …

import wixUsers from 'wix-users';
import wixData from 'wix-data';

//--------- User-Interface -------------
let REPEATER = "#repeater3"
//--------- User-Interface -------------

$w.onReady(()=> {
  $w(REPEATER).onItemReady(($item, itemData, index) => {
  //---Activity---------------------------------------------------------
    if (itemData.activity) {
      $item('#btnActive').show();
      $item('#btnActive').style.backgroundColor = "rgb(255, 0, 0)";
    } 
    else {
      $item('#btnActive').hide();
      $item('#btnActive').style.backgroundColor = "rgb(0, 0, 255)";
    }
    //---Contract---------------------------------------------------------
    if (itemData.contract) {
      $item('#btnContract').show();
      $item('#btnContract').style.backgroundColor = "rgb(255, 0, 0)";
    } 
    else {
      $item('#btnContract').hide();
      $item('#btnContract').style.backgroundColor = "rgb(0, 0, 255)";
    }
  });
});

By the way —> When giving your ELEMENTS a name(ID), do it more efficiant and logical.

-when ELEMENT is a BUTTON --------> ID = btn+ButtonNanme → “btnActivity”
-when ELEMENT is a DROPDOWN → ID = dd+DropdownNanme → “ddXXXXX”
-when ELEMENT is a CHECKBOX ----> ID = cb+CheckboxNanme → “cbXXXXX”

and so on…

Why doing this way?
→ for better reading your own code
→ especialy for those → who do not know your project (extern-coder) like me :wink:

You are my Ninga. Thank you for all the hard time you gave me and I do appreciate all your help. Now to the next project even velo team could not help