-->
Page 1 of 2

Dropdown passing a numeric from the selected text in the box

PostPosted: Sat Jul 23, 2016 4:20 pm
by Ecoli-557
Hello to All-
I am a noob to this forum and thanks to Mike - I now have some NodeMCUs which are working!
My question is this:
Is there a way that a Dropdown box can be used which would be filled with text, BUT, in which the variable is passed the NUMBER of the text in the Dropdown?
Example, say I have a Dropdown and it is to get the day of the week into var DOW. The box has Sunday, Monday, Tuesday..... Thursday, Friday, Saturday.
I do not want the text going into the Var, just the number which is associated with the selected element in the box.
In my example I selected Wednesday which I want DOW=4 (Sunday being 1).

Is this even possible? Apologies if this is somewhere I did no see.
It is similar to having a LOOKUP or a LOOKDOWN function.......
Regards to All.

Re: Dropdown passing a numeric from the selected text in the

PostPosted: Sat Jul 23, 2016 11:02 pm
by forlotto
It used to be possible to do this I don't know if it still is the way varibles are handled in the 3.x branch seems to differ from previous versions and really even earlier versions than this the points at which you can call variables or track variables has changed and so have the methods I'm trying to figure this all out myself it is a fairly consistent learning curve.

But surely something similar was done at a point with wifi they would scan wifi's and put the access points in a dropdown list then allow you to select and connect to it with a password. Errr I cannot remember where the example was but if you work on this line by line just editing in your code you may be able to come up with something.

Re: Dropdown passing a numeric from the selected text in the

PostPosted: Sat Jul 23, 2016 11:11 pm
by forlotto
Here was the code I was talking about:

Code: Select all[WifiSettings]
let listWifis = ""
n = wifi.scan()
n = n - 1
html "Number of network found = "
html n
for x = 1 to n
let listWifis = listWifis & wifi.ssid(x)
let listWifis = listWifis & ","
next x
wprint "<br>Select SSID: "
dropdown listWifis selectedWifi


might not be exact but should be a start something to build off of.

Re: Dropdown passing a numeric from the selected text in the

PostPosted: Sun Jul 24, 2016 6:09 pm
by Ecoli-557
Thanks! I will give that a shot and if not, perhaps a number of IF-THENs?
Anybody know how deep the stack is for nesting IF-THENs?
Regards to All.