webpopupmenu.listindex

Hi all!
I have a problem: when I read some data from the database, my webapp has to set one webpopupmenu selecting the string stored in the database. To do this I’ve written this method

[code]Sub SelectTextInPopup(text As string, popupsel As webpopupmenu)
Dim i As Integer

for i=0 to popupsel.ListCount-1
if popupsel.List(i)=text Then
popupsel.ListIndex=i
exit
end if
Next
End Sub
[/code]

This is the exact code I use for desktop app, where it works nice! But in webapp it do nothing! When from my code I call SelectTextInPopup(“The Text”,MyPopup) the method works nice… I mean that in the debugger I can see that the row popupsel.listindex=i has been executed, but in the app window the popupmenu has nothing selected!

Any suggestions about this problem?

Many thanks!

I add this info:
If I use this code in a button

[code] dim i As Integer

i=1

MyPopup.ListIndex=i[/code]
it doesn’t work, and if I use this code

  MyPopup.ListIndex=1

it works! Anyone has got an answer?

Many thanks!

I use the exact same code in 6 different live web applications and have no issues at all. But I catch it if it does not exist.

[code]
Sub SetPOPUP(TheText as String, ThePopUp as WebPopupMenu)
Dim gotit As Boolean = False

Dim i As Integer
For i = 0 To ThePopUp.ListCount -1
If ThePopUp.list(i) = TheText Then
ThePopUp.ListIndex = i
gotit=True
Exit
End If
Next

If Not gotit Then

msgbox "Error in SetPOPUP"

End If

End Sub[/code]

You could also use IndexOfRow in a Webpopupmenu to simplify the routine.

http://documentation.xojo.com/index.php/WebPopupMenu.IndexOfRow

Jim

It seems a nice idea Jim, but it does not work for me… I don’t know why, but may be because 3 rows above in my code I populate the webpopupmenu (with data taken from a database) and it’s not yet refreshed…
I’m going to make some tests now and I’ll let you know.

Ok, I confirm what I say in my last message: few lines above the code I use to select the webpopup menu row, I refresh (deleteallrows and re-populate) the webpopupmenu, and when I use listindex=n is probably too soon!
Now I refresh the webpopup menu in the open event of his container and it works!

Many thanks to all for you precious support!