[Closed] Drop Down + Text Box in one?
I’m trying to figure out how to create a text box which is also a drop down box.
I would like for the drop down to include some options like “ABC” “BCD” “EFG” which if selected fill in the text box. Otherwise the person can just type in something arbitrary of their choosing.
Do I need to do this through activeX?
But wouldn’t that be two boxes?
I would like to do it all in one… unless hehe… I put the drop down behind the text box… and then set it off to the side so only the arrow stuck out… hmmmm… that just might work.
Eureka!
A new way of entering data is born!
--Create Rollout
try destroyDialog dialogname catch ()
rollout drop_text_test "Drop_Down_Textbox"
(
edittext txt "" fieldWidth:160 pos:[5,12] labelOnTop:true
dropdownlist drop_dwn "" width:180 pos:[5,10] items:#("", "opt1", "opt2", "opt3", "opt4")
on drop_dwn selected i do
(
if drop_dwn.items[i] != "" then
(
txt.text = drop_dwn.items[i]
)
else
(
txt.text = txt.text
)
)
)
createDialog drop_text_test 200 100
Now just for the sake of clarity I need to figure out a way to dynamically update the #1 option to txt.text. Hmmmmm… how to do this…
--Create Rollout
try destroyDialog drop_text_test catch ()
global theItems = #("", "opt1", "opt2", "opt3", "opt4")
rollout drop_text_test "Drop_Down_Textbox"
(
edittext txt "" fieldWidth:160 pos:[5,12] labelOnTop:true
dropdownlist drop_dwn "" width:180 pos:[5,10] items:theItems
on drop_dwn selected i do
(
if drop_dwn.items[i] != "" then txt.text = drop_dwn.items[i]
)
on txt entered thetext do (
theItems[1] = txt.text
drop_dwn.items = theItems
)
)
createDialog drop_text_test 200 100
Closer, but it needs one seemingly redundant change to keep the text box active while typing:
--Create Rollout
try destroyDialog drop_text_test catch ()
global theItems = #("", "opt1", "opt2", "opt3", "opt4")
rollout drop_text_test "Drop_Down_Textbox"
(
edittext txt "" fieldWidth:160 pos:[5,12] labelOnTop:true
dropdownlist drop_dwn "" width:180 pos:[5,10] items:theItems
on drop_dwn selected i do
(
if drop_dwn.items[i] != "" then txt.text = drop_dwn.items[i]
)
on txt entered thetext do (
theItems[1] = txt.text
drop_dwn.items = theItems
[b]txt.text = txt.text[/b]
)
)
createDialog drop_text_test 200 100
Is there a property to lock the ‘length’ of a text field in characters? Like only allow 3 characters? Also is there a way to set the cursor to a specific text box. So for instance I put a conditional where if the user attempted to enter a 4th character (assuming a maximum of 3 it would send the cursor to another text field. Sort of like in a web form where you can set it to got to the next text box while entering a phone number and it jumps from area code etc… etc…
I suppose this could work but it seems kind of sloppy
if product_box.text.count > 6 then product_box.text = substring product_box.text 1 6