ComboBox to Field Script?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
rfulper
Posts: 1
Joined: Mon Mar 10, 2014 9:30 pm

ComboBox to Field Script?

Post by rfulper » Thu Mar 27, 2014 8:13 pm

This may sound funny but I have little experience with scripting and in my LiveCode application I have a combo box where a user can select a number from 0 through 10. Once the selection is made, I would like that number to populate into a normal text field. Can anyone tell me how to achieve this?

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: ComboBox to Field Script?

Post by Dixie » Thu Mar 27, 2014 9:09 pm

look at the script of your combobox..

Code: Select all

on menuPick pItemName
   put pItemName into fld "whatevername"
   switch pItemName
      
   end switch
end menuPick
put 'put pItemName' ( which is the number you have selected) into fld "whatevername' (the fld where you want the number you have selected to be placed.)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10354
Joined: Wed May 06, 2009 2:28 pm

Re: ComboBox to Field Script?

Post by dunbarx » Thu Mar 27, 2014 10:06 pm

Hi.

If you need the information upon selecting from the combo itself, do just what Dixie suggested. But know that with all such menu-style buttons (pull-down, option, etc) the menuHistory is a property, and can be obtained at any time from other sources:

answer the menuHistory of button yourMenuButton. --might yield "3", if the third line was chosen

In your case, the line chosen looks like it is also the contents of that line, or the "label". This "label" is also a property, and gives the text of the displayed line, but ONLY with comboBox and option styles. Pull-down and pop-up styles will return empty. I am not sure why. Anyway, you should experiment with these three methods of extracting information from these objects. Especially use the "switch" construction pre-set into the scripts. Dixie ignored this portion of code in his example, since it was not needed to answer your question.

Craig Newman

Post Reply