[widget] Set pop-up menu selected value

I'm trying to develop a widget where I need to set the initial value of a pop-up menu in runtime.
I tried this:
var pm=document.getElementById('popup').childNodes[2];
pm.selectedIndex=n;
I had already tried with:
pm.options[n].selected=true;
Although this sets the selected element, it continues showing the previous selected element.
What is the best method to set the selected value of a pop-up menu?
Is there any method that allows me to set both the selected value and the showed value?
Message was edited by: rcg.pt

I think you're working against the HIG...

Similar Messages

  • JComboBox event notification when select first entry in pop-up menu JDK 6

    I recently began testing a Java GUI, I originally developed with JDK 1.5.0_11, with JDK 1.6.0_3. I have used the JComboBox in several applications developed using JDK 1.3.x and 1.4.x over the years. In every one of these earlier JDKs the JComboBox widgets all behaved the same. When you select the JComboBox widget, the pop-up menu appears and you can select any of the items from the menu list. Having made the selection with either a mouse click or a key press, an event notification is sent. Typically, an ActionEvent as well as either a mouse click event or a keypressed event may be sent. When testing with 1.6.0_x versions of the JDK and JRE, I can't account for any event notification being sent when selecting the first item at the top of the pop-up menu as the initial selection. If I select some other item on the list and then the first item, it works as it is supposed to work, but only after selecting another item first.
    I've placed the JComboBox in a JDialog and a JPanel. There are NO AWT widgets in any containers of the application. The same behavior seems to exist regardless of what other containing Swing component I place the JComboBox in. I'm running these applications on Windows XP, service pack 2. The system is an AMD 64 bit dual processor with 4Gb of RAM. The essential code follows:
    private JComboBox getJcboAlias()
        /* Note here that I am using a defaultComboModel as I have always done */
       jcboAliases = new JComboBox(urls);
       *jcboAliases.setEditable(false);*                               // Note here that the JComboBox is NOT editable
       jcboAliases.addActionListener(new ActionListener()   // ActionListener only receives a notification if the second or
       {                                                                            // another item in the pop-menu list is selected...but never the
          public void actionPerformed(ActionEvent ae)           // first item in the list
             String s = (String) jcboAliases.getSelectedItem();
             for (int i = 0; i < connections.size(); i++)
                conAlias = (String[]) connections.get(i);
                if (s.equals(conAlias))
    isSelected = true;
    break;
    jlblName.setVisible(true);
    jlblAlias.setVisible(true);
    jlblUID.setVisible(true);
    jlblPWD.setVisible(true);
    jtxtName.setText(conAlias[0]);
    jtxtName.setVisible(true);
    jtxtAddress.setText(conAlias[1]);
    jtxtAddress.setVisible(true);
    jtxtUID.setText(conAlias[2]);
    jtxtUID.setVisible(true);
    jtxtPWD.setVisible(true);
    jtxtPWD.setText("");
    jtxtPWD.requestFocus();
    return jcboAliases;
    }    I'm using a non-editable JComboBox because there is a pop-up menu with this and not with the JList widget.  JComboBox behaves more like the JList MicroSoft counterpart.  Another code snippet follows in which the JComboBox is editable.  The same errant behavior occurs when selecting the first item from the pop-up menu: private JComboBox getJcboPCMember()
    jcboPCMember = new JComboBox(PCViewerCustom.getCurrentMembers());
    jcboPCMember.setBounds(250, 103, 180, 20);
    jcboPCMember.setToolTipText("PATHCHECK(ER) member name - Example: CKPPTHCK");
    jcboPCMember.setSelectedIndex(Integer.valueOf(PCViewerCustom.getCurrentHost(3)));
    jcboPCMember.setEditable(true); // Note here that this JComboBox IS editable
    jcboPCMember.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
    if (ae.getActionCommand().equals("comboBoxEdited"))
    boolean copy = false;
    for (int i = 0; i < jcboPCMember.getItemCount(); i++)
    if (jcboPCMember.getSelectedItem().equals(jcboPCMember.getItemAt(i)))
    copy = true;
    break;
    if (!copy)
    if (jcboPCMember.getItemCount() > 0)
    if (jcboPCMember.getItemAt(0).equals("No Entries"))
    jcboPCMember.removeItem("");
    jcboPCMember.removeItem("No Entries");
    jcboPCMember.insertItemAt((String) jcboPCMember.getSelectedItem(), 0);
    else
    jcboPCMember.removeItem("");
    jcboPCMember.addItem((String) jcboPCMember.getSelectedItem());
    enableJbtnOK();
    else
    if (jcboPCMember.getSelectedIndex() >= 0)
    PCViewerCustom.setCurrentHost(3, Integer.toString(jcboPCMember.getSelectedIndex()));
    enableJbtnOK();
    else
    JOptionPane.showMessageDialog(null, "Name not selected", "Error", JOptionPane.ERROR_MESSAGE);
    return jcboPCMember;
         I am able to add a new entry to the JComboBox, however, I am still unable to select the first item from the pop-up menu and fire any kind of notification event.  I have not seen this behavior before in any earlier versions of the JDK and it's playing havoc with my ability to deploy the application into a JDK or JRE V6 environment, without adding a bunch of additional code to pre-select the first item on the list, which pretty much defeats the purpose of the JComboBox.  I'll be the first to admit I've done something wrong, but i've built a number of test scenarios now on two systems runing Win XP SP2 and I get the same errant behavior.  I've also added in event listeners for a MouseListerner, a KeyListener and an ItemListener.  Still no event notification on this first item in the list.  Again, however, if I select one of the other items from the pop-up menu list and then select the first item, all is well.  Imagine selling that method of operation to a user....  It occurs to me that this must be a bug in the V6 JComboBox.  I wanted to post this here first, however, in order to determine if this is, in fact, a bug - in other words, am I the only one seeing this, or is this a more widespread issue?  Any assistance in making this determination is greatly appreciated.
    David Baker
    Edited by: Galstuk on Nov 27, 2007 12:21 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    here is the other file as well:
    Harold Timmis
    [email protected]
    Orlando,Fl
    *Kudos always welcome
    Attachments:
    VI2.vi ‏5 KB

  • Get menu selection help

    Hi I am new to the Labview world and am having a bit of an issue with the get menu selection vi.  I opened an example (Queued Message Handler.vi) and basically copied that get menu selection setup in my vi.  Yet all i get for menu selections are null strings.  I have tried to set the get menu selection timeout to -1 then selecting a menu item.  I still get a null string from it so I know it isn't some timing issue.  I have attached a copy of my vi.  The runtime menu I was using was just File with an exit option.  There are a couple sub vi's that i made that are required to run Queue.vi but they arent really needed to see what I am doing.  Thanks for any help in advance.
    Attachments:
    Queue.vi ‏59 KB

    Hi Superseadragon,
    I recommend you to use an event-driven state machine desing pattern that combines a queued state machine and event structure into a hybrid single-loop design pattern.
    I made an example with your code but as I don't have your set up I put in commentary all the communication function.
    To close the VI click on the cross on the upper right corner like for a tradionnal application.
    You can fire an event from the run time menu. I included a case in the event structure. Have a look at it. This is not the only way to do it.
    Have fun with your algae!
    Charly
    It's always sunny in California! Certified LabVIEW Associate Developer!
    Attachments:
    SuperSeaDragon.zip ‏135 KB

  • Changing Pop-up-Menu

    Hello!
    Is it possible to open up a Pop-up-menu - depending on the previous Input?
    Example:
    2 columns.
    first column: Pop-up-menu selection "A" or "B"
    second column depening on the previous Input. If you chose "A" -> Pop-up menu "1" or "2". If you chose "B" -> Pop-up menu "3" or "4".

    Hi toni,
    I have been playing with this idea of conditional pop-ups. This is what I have now. I used rows, not columns. Not the sort of thing I would want to do in bulk. With the 13 rows you can choose 3 aspects. You would use column B to extract data to your data table.
    B2= IF(A$1="Red","show","")
    B10= IF(A$1="Green","show","")
    B7= IF(A$6="Sky","show","")
    B8= IF(A$6="Teal","show","")
    B9= IF(A$6="Aqua","show","")
    That should give you the idea.
    Column B can be hidden.  The choice made in A1 determines which of A2, A6 or A10 can be seen. When the filter is on only one "choose shade" row is revealed. Once a shade is selected a quality can be chosen.
    Does this seem useful?
    quinn

  • I want to create an external video widget with iAd. I followed the steps and copied the Url and paste it in the Video pop-up menu in the Properties section of the inspector. When i select 'preview' the video doesn't play and the Url that i pasted is gone.

    i want to create an external video widget with iAd to use in an iBook. I followed the steps and copied the Url and paste it in the Video pop-up menu in the Properties section of the inspector. When i select 'preview' the video doesn't play and the Url that i pasted is gone.
    hope someone can help!

    May have something to do with whether or not the URL can be reached while building your widget.  I've got a video on the web. When I enter the URL into the field for the video object and click to another field,  the URL is replaced with some text indicating that it is accessing the video then updates itself to displaying just the name of the video file.
    It shows just fine in preview and I can see the full path to the video when I export the widget so it should work for you. 
    Is the video accessible from your Mac while you're laying out your widget?
    -Mark

  • Using COUNTIF on time values in pop-up menu (employee schedule template)

    I have modified the Numbers employee schedule template to my liking and it works very well. I would like to add a column to the beginning which shows, at a glance, how many people I have scheduled for AM shifts and PM shifts on a given day. My AM shifts start at 9:00 AM and my PM shifts end at 6:30 or 8:30 PM.
    So I thought I could use COUNTIF, but after I set the array, I cannot get the condition right to return anything except "0". How do you make it detect the appropriate times? The times in each cell for In and Out times are selected using a pop-up menu, just like the template.
    Here is what I tried: =COUNTIF(E3:AE3,"9:00 AM")
    What should the condition be to return a proper count?

    ac,
    You shouldn't feel badly about having trouble with this template. It is a rather tricky one. The values in the Pop-Up menus are Date/Time values. That is to say, they have year, month, day, hour and minute components, even if only the hours and minutes are displayed. So if you only compare to the hours and minutes, you will never get a match.
    I don't know if you have experienced this yet, but when you changed the Pop-Up menu content, you probably entered the current year, month and day unknowingly and will have trouble doing math against the Pop-Up content that was originally in the template.
    My suggestion in your case would be to convert the time references to decimal hours before doing a comparison. For instance, if the time you wish to compare to is in cell C4, you could extract the decimal hours with =HOUR(C4)+MINUTE(C4)/60
    Remember that the hours will reflect a 24-hour day, so times in the afternoon will run from 12.0 to 23.99...
    Then after converting to decimal, instead of using "9:00 AM" for the COUNTIF criteria, use 9.
    There are probably ways to do this using the Duration format as well, but I prefer the decimal hours.
    Hope this helps.
    Jerry

  • Can I change the fill color of an entire row based on what's selected in a pop-up menu in the first cell?

    I have a pop-up menu in the first cell of every row with three choices (and I may add more at a later date).  I want the fill color of the row to change depending on which thing is selected.  Is this hard to do?

    Hi,
    In essence the same as Wayne's answer, but with a slight modification to fit  to duplicate your 'color the whole row' specification. The final result, with Table 2 slid behind Table 1, is shown.
    Table 2 is a single column table with the same number of rows as Table 1. The table is resized to match the full width of Table 1.
    In A2, use the formula =Table 1::A2 to copy the value from that cell in Table 2. Fill the formula down through the rest of the column.
    Select all the cells in Table 2 (except the header row), and apply conditional formatting rules such as those below.
    Note that the Conditional Format rules are set to apply the same colour to text and fill in the cell, so that the text disappears.
    When Table 2 is ready, select it, then go Arrange > Send to Back.
    Before sliding Table 2 behind Table 1, Select Table 1 and use the Table Inspector to set the Cell Background to None (see red arrow in illustration). If This table has a Header column, you need to select the header cells independently and again set the Cell Background to None.
    Now select Table 2 and drag it to a position partially under Table 1. When you see the blue alignment guides on both sides, or at the top and bottom, of Table 1, release the mouse button and use the arrow keys to nudge Table 2 into its final position.
    Regards,
    Barry

  • Pop-up menu to list multiple time values (8:00 AM etc.) ?

    I was looking at the option of using a pop-up menu to select times (8:00 AM etc.) from to keep from having to enter all the times in my spreadsheet manually. Has anyone done this before and is there a download or widget for this? Unfortunately for me, I would need it to be in increments of 5 minutes starting from 7AM to 7PM or so, which would be a tremendous amount of parameters added to a traditional pop-up menu.
    Thanks for any input.

    T25 wrote:
    Thanks for the insight, it seems to make good sense to me with your process to create multiple pop-ups and/or sliders. Since I'm still new to iWork Numbers though, are the tables you illustrated in your reply saved in a separate spreadsheet to use as a reference for the pop-up in other, separate spreadsheets? Is that what LOOKUP is used for (to reference another sheet)?
    My invoice has a single cell for an "IN" time and another for an "OUT" time; all incorporated to a fairly "busy" invoice that can't accommodate any additional cells in those areas.
    Both tables are on the same sheet, but I placed them on separate tables on that sheet.
    They don't have to be on separate tables, and they don't have to be on the same sheet, but they do have to be in the same document, as Numbers does not provide for linking to separate documents/files.
    With the busy invoice in your case, you could place the popup and slider cells (two of each) on a separate table, and only the result cells on the same table as your invoice. The popups and sliders could go on the same table as the lookup array, but that table would then have to be both visible and unlocked.
    Placing the Lookup array on a separate table allows you to lock that table to prevent accidental changes to it. You can also easily hide the Lookup table by placing it behind the main table (your invoice), or on a second sheet in your document.
    Placed on the same table as the rest of the invoice, you can still hide it simply by hiding the two columns containing the lookup information.
    An alternate method, requiring no extra cells or tables would be to Use Insert Date and Time (in the Insert menu, or from the keyboard with shift-option-command-D ) to insert the date and time directly.
    There are some complications with this which might make it unusable, depending on how many people need to be trained and how well they take to training. Insert Date and Time starts with the assumption that what you really want to do is insert the date. Changing its mind takes a couple of extra steps that must be done immediately, and each time.
    1. Click on the cell to select it.
    2. Go Insert > Date and Time (or press shift-option-command-D )
    3. Before taking any other action, double click the cell (which will now be displaying the current date) to open a small dialogue.
    4. In the dialogue, use the popup menu to choose one of the Time only formats.
    5. Click outside the dialogue to dismiss it.
    The cell will now contain the current Date and Time value, and will display the current time.
    Note that the Time, when inserted this way, will be the time that the insertion was done, and won't be rounded to the nearer five minutes.
    You'll find a discussion of LOOKUP (and the two related functions, VLOOKUP and HLOOKUP in the iWork Formulas and Functions User Guide, and an excellent overview of Numbers (including explanation of the terms I've used above) in the Numbers '09 User Guide. Both can be downloaded using the menu items in the Help menu in Numbers. Both are recommended reading for new and old users of Numbers alike.
    Regards,
    Barry

  • How do you assign a value for Products in a Pop-up menu?

    I am preparing production cost spread sheet. In one column I2 - I have a pop up menu with lamination types to be selected - ie: None, Standard Film, Vehicle Film, Liquid Coating. I want to be able to associate values of these costs in column J2 - On another table (Laminating Costs) I have set values for each product ie: None = 0, Standard Film = $1, Vehicle Film =$2 and Liquid Coating =$0.5 -
    Therefore if I select Liquid Coating from the from the Pop-up menu in I2 on the main spread sheet - I want to see the associated cost of $0.5 appear in J2 by referencing the Laminating Costs table - I have tried various SUMIF formulas with no luck - Could someone point me in the right direction please.
    Thanks

    You can assign values to the items using a lookup table.
    http://discussions.apple.com/thread.jspa?threadID=2539456&tstart=0

  • Pop-up menu in one column determines the value in another.  How?

    I'm setting up a company report, and one column has a pop-up menu.  I want the cell in another column to automatically enter a certain value depending on which option is selected in that pop-up menu.  How is that done?

    m,
    You can use any of the functions that look for a match in one column and pull data from another. As a class, they're called Lookup functions. I wouldn't plan on having your design survive an export to Excel, so you should consider who will be using your work and what platform they will have available.
    Jerry

  • Chart from pop up menu values

    I have a table that lists project names on the Y axis and a month/year designation on the X axis.  For each project, I have a status assigned for each month.  The statuses are selected from a custom pop-up menu in the Numbers table. 
    I would like to create a bar chart that uses the same Y and X axis labels, but designate a different color for each status and have it displayed on the bar.  Attached below is a graphic of a manually updated table in Excel that I would like to automate in Numbers.

    Wayne's suggestions regarding software dedicated to this purpose is well taken. Here are some further thoughts on using Numbers to produce a GANT-like chart.
    The first is similar to what you appear to have done in Excel—each month is represented by a coloured cell. In the example below, I've used a pop=up menu in each cell to select one of the stages in your projects, and conditional formatting to set the colour of the cell and the text according to the choice made.
    I chose slightly different colours for the text and fill so that the text resulting in the colours can be seen. Pretty much a hands-pn do-it-yourself solution; no bells or whistles at this point.
    The second, below is a bit closer to automated, but has some flaws, nted below the images.
    "Data" is the table on which the start dates for each stage are recorded. Where one stage is skipped (as in Project 2) the 'start' date for that stage (evaluation) is set to the same date as for the next stage.
    For chart is an auxiliary table, where DATEDIF(start,finish) is used to calculate the number of days between beginning and end of each stage. The chart is a Stacked Bar Chart, with the first bar's fill set to 'none'.
    For Chart uses three fomulas:
    A2: =Data :: A2
    This copies the project name from the first column of "Data". Fill down from A2.
    B2: =IFERROR(DATEDIF($A$1,Data :: D2,"D"),"")
    Fill down to the end of column B.
    A1 of this table contains the date and time value for the last day of the previous year (Dec 31, 2011 00:00:00). I've left this displayed , but it could be hidden.
    Data::D2 contains the start date for the first stage (Exploring) of the project.
    C2: =IFERROR(DATEDIF(Data :: D2,Data :: E2,"D"),"")
    Fill down the rest of column C, and right to column F (Delivery).
    This is the same formula as in column B. It differs only in the cell references containing the dates between which the difference is calculated.
    The chart is constructed by selecting cells B2:F5 on For Chart, then choosing the (horizontal) stacked bar chart from the Chart button's menu. Click the three bars icon that appears at the top left of the selected cells to change from 'series in column' to 'series in row'.
    Limitations:
    Except for a scatter chart,Numbers charts cannot use Date and Time values on a Value axis. Here, I've used numbers representing the day-of-year number.
    Numbers permits a maximum of 10 divisions on a Value axis, which isn't enough to break a year into months. The best possible, for appearance, is to set the maximum to 360 days, then use six divsions, each 60 days, to place the vertical grid lines.
    If you also fix the size of the chart, you could replace these numbers along the x axis with the equivalent dates, entered into one or more text boxes, then spaced to match the chart's vertical grid lines (and points between these lines).
    An interesting exercise, but not, I'm afraid, a fantastic solution.
    Regards,
    Barry

  • How can I show a pop up menu based on the selection in a previous pop up menu?

    For example, if "Company" is selected in a pop up menu in C6, then show another pop up menu in C7. if "Bob" is selected in a pop up menu C7, show another pop up menu that contains the talks "Bob" has in C8.
    I am trying to create a talk scheduling spreadsheet with different talk outlines for different speakers. I'm not sure if there are any functions or formulas that can accomplish this. Can anyone help?

    Pop-up menus contain fixed values in Numbers. You might be able to do this using Steppers or sliders. These produce a numerical result, which could be used to direct a second slider or stepper's output to a specific column or table.
    If you can provide a map of the structure of your list(s), there may be someone here able to take on the task of constructing the tools to do the job.
    Regards,
    Barry

  • Pop-up menu values from table cells rather than hard-coded?

    Hello,
    I'd like to have a pop-up menu that allows the user to select a category from the list. However, I want that list of categories to be dynamic. I have a table with all of my categories, and I want a pop-up menu that allows me to select one of the values in that table. I change "foo" to "bar" in the table containing the pop-up menu options, and I want the user only to be able to select "bar" in the pop-up menu (bonus points if all past instances of "foo" in the user-entered table are automatically changed to "bar" as well).
    While I'm at it, is there any way to have conditional formatting based on my dynamic categories? I.E. ROYGBIV color order for my categories corresponding to alphabetical order of categories, even though the category labels my change over time or some may be added or deleted.
    BTW, I have already downloaded the Numbers reference guide and formula guide.
    Any suggestions appreciated. Thanks very much,
    Adrian

    Question asked and responded many times :
    *_Feature unavailable_* .
    In several threads, Jerrold Green described a tip which may be used to mlimic this missing feature.
    You may use the Search tool :
    One returned link for the 90 days period.
    I checked, it's a good one.
    Yvan KOENIG (VALLAURIS, France) lundi 5 juillet 2010 19:19:21

  • Using a pop up menu to assign selections to a number

    Hello,
    I'm trying to setup a bonus calculator based on a pop up menu box selection.  The pop up menu box contains 3 different job levels.  I wanted to assign each job level to a number.  Then I have a different formula using that result in its selection of data.  What would be the best route to go about this? I thought an if statement but not having much luck. =IF(C9='Restaurant','1',=Else(C9='Market','2',=Else(C9='Region','3')))
    Cell C9 is my pop up menu with selections of Restaurant, Market, Region
    Thanks for the help everyone. For some reason my mind is blocked at the moment.
    Billy Grace

    If you have only three possible values then a nested IF statement can do the job:
    =IF(C9="Restaurant",1,IF(C9="Market",2,3))
    Not there is no explicit "else" in the syntax. The "else is implied.
    =IF(<expression>,<value displayed if the expression is true>, <value displayed if expression is not true, i.e. the "else">)
    If you have more than three possible values, then a lookup table will be more practical.
    SG

  • Pop-up menu with defined values

    I am working on creating an invoice in Numbers and am wanting to create values that are tied to my pop-up menu on a cell. For example, if 'Travel day' is selected on my pop-up menu in cell A2, then I would like $300 to come up in cell C2 automatically. Or, if 'Work day' is selected in cell A2, then I would like to have $450 come up in cell C2. Is this possible? Help please

    You pop-up will need three values: a 'blank' (actually a single space character), Work day, and Travel day.
    For C2, you could use a pair of nested IF statements:
    =IF(A="Work day",450,IF(A="Travel day",300,"")
    For a menu with more possibilities, you might want to take a look at LOOKUP or VLOOKUP in the iWork Formulas and Functions User Guide.
    The guide can be downloaded via the Help menu in Numbers. The search function in the guide will take you quite quickly to a description of either of these functions, with examples of how each may be used.
    Regards,
    Barry

Maybe you are looking for