Page 1 of 1

Change from one type box then back?

Posted: Sat Jun 20, 2009 9:59 pm
by TodayIsTheDay
Can I have a text box, when you click on it once, turns into a combo box (so you can choose something from the database) then when you select something, have it turn back into a text box?

I don't want a page filled with combo boxes is the reason for this.

I'm just looking for a clean looking page but still have the ability to grab things from a database...

If there is a better or easier way to do this please let me know. That's just the way that came to mind...

Thanks,
Patrick

Posted: Sat Jun 20, 2009 10:56 pm
by SparkOut
There's probably lots of ways to do something with this, but one to try may be:

Put a field on the stack (in this case "fldPseudoCombo"). Put a combo box menu on the stack (in this case "btnPseudoCombo").

Make the sizes the same, and align them on the stack so that they are on top of each other, with the field on top and hiding the combo box. Then when anyone selects the field, hide it, so that the combo box is visible in its place, and when the combo box item is selected, show the field (with its new contents).

In the script of the field, use code such as:

Code: Select all

on openField
   hide me
end openField

on closeField
   -- this handler should really be redundant, as the "show" command will be triggered in the menuPick handler of the combo box
   show me
end closeField
In the script of the combo box button, use code such as:

Code: Select all

on menuPick pItemName
   switch pItemName
      -- any processing you want to happen dependent on the menu item selected
   end switch
   -- then copy the selected item to the field and show it
   put pItemName into field "fldPseudoCombo"
   show field "fldPseudoCombo"
end menuPick
You may want to experiment with locked text and unlocked text in the field, so also have a look at the focusIn and focusOut messages.
HTH