Drop down Error

Hi all,

I want to insert a drop drop-down which is displaying the values of the database column which is of type “number”. It is throwing an error that values should be of string type.

  1. is there any way to fix it without coding ?

  2. if No for 1 which API to use for storing the values in dopdown .
    I used
    for( let i=0;i<totalNum ;i++)
    {

           test[i]={label: item[i].quiz_num , value: item[i].quiz_num}; 
           test[i].label=test[i].label.toString(); 
           test[i].value=test[i].label.toString(); 
           $w("#selection1").options[i]=test[i]; 
          } 
    

but it is not working

can you help if this method of adding the values is correct ?

screen shot of my sample database

Hi Japinder,

Your code does the right thing. The only thing you need to change is the last line, from

$w("#selection1").options[i]=test[i]; 

To

$w("#selection1").options=test;

Hi ,

Thanks for the correction One last thing .
which event should i place drop down code i have tried few options as follow

  1. on ready :- the options and values are not loading , so on clicking the drop-down its not expanding. do i need to add some expanding code here(in face after query its not even entering the above for loop).

  2. on click :- working , in this when i am clicking 1st time then nothing happen but from 3nd click onward it works perfectly and the drop down list opens;

3)on render:- its not working

this is the 2nd way… rest of the ways not working


so if i put the code in the Selection4_Click_1 in on render or if i merger it with fill function and call the fill fucntion from onready or onrender its not working .

Any way that when the user click 1st time only the drop down list open .

Thanks for the help :slight_smile: