Array of radio buttons

Hi everybody,
i have to implement an interface where the number of radio buttons depends on the elements of an String [ ], so i am trying to implement it as an array (I do not know any other method). But the prblem i�m getting back some mistakes.
String[] chain= new String [3];
chain[0]= "uno";
chain[1]= "dos";
chain[2]= "tres";
//Add everything to a container.
Box box = Box.createVerticalBox();
box.add(label1);
box.add(Box.createVerticalStrut(isotopos.length));
for (int i=0;i< chain.length;i++)
JRadioButton[ ] rb = new JRadioButton();
rb.setText(isotopos[i]);
rb[i].addActionListener(this);
rb[i].setSelected(true);
bg1.add(rb[i]);
anyone knows how to do it? Thanks

JRadioButton[ ] rb = new JRadioButton();
That line is invalid: you can't assign a JRadioButton to a type JRadioButton[].
In any case, you want to assign your array outside the loop if you want to assign its elements inside.
And besides that, you don't even need to create the array. Just create the buttons and add them to the box, unless you need to retain references to them (in which case a local array is probably useless anyway).
And don't forget radio buttons need to be grouped.

Similar Messages

  • Using an array to assign values to 36 radio buttons

    Okay, here's another doozy for y'all.
    As some of you know, I'm trying to create a character creation program for D&D. When we roll ability scores, we roll 3 sets of 6 rolls, rolling 4 six-sided dice, rerolling 1s and dropping the lowest number, then add the highest 3 rolled numbers together.
    Great! Got that part done!
    The next thing I'm having some issues with is transferring those numbers to radio button text property. What I have done is created a form that has the rolled values in listboxes so the user can see what was rolled. They can only choose one "set"
    of rolls, so each set of 6 rolls is in a separate listbox. I can get the values from the listbox to an array, but I can't figure out how to get the values from an array to the radio buttons on the next form in the program.
    The next form in the program has 6 group boxes, each labeled with a different ability score name (ie: Strength, Dexterity, etc.). Also in each group box are 6 radio buttons. Each radio button in each group box needs to have the same values. For example,
    the first listed radio button in each group box needs to have the first value listed in the list box on the previous page. The second listed radio button in each group box needs to have the second value listed in the list box, and so on. I want it
    to automatically load, but I'll settle for ANY load at the moment!
    The other thing is that I don't want to write 36 lines of code for each group box's radio buttons! I would like to be able to populate the values with a loop. So, the biggest question is how to create an array containing all 36 radio buttons, then assign
    my list box values to them according to their position in the multidimensional array.
    Here is a tidbit so you'll have an idea what I'm looking at.
    list box 1 has values 17, 18, 8, 12, 15, and 13. I want the radio buttons in each group box on the second form to be 17 for the 1st radio button, 18 for the 2nd radio button, 8 for the 3rd radio button, 12 for the 4th radio button, 15 for the 5th radio
    button, and 13 for the 6th radio button.
    Any ideas?

    The array of radio buttons:
    radGr1_1
    radGr1_2
    radGr1_3
    radGr1_4
    radGr1_5
    radGr1_6
    radGr2_1
    radGr2_2
    radGr2_3
    radGr2_4
    radGr2_5
    radGr2_6
    radGr3_1
    radGr3_2
    radGr3_3
    radGr3_4
    radGr3_5
    radGr3_6
    radGr4_1
    radGr4_2
    radGr4_3
    radGr4_4
    radGr4_5
    radGr4_6
    radGr5_1
    radGr5_2
    radGr5_3
    radGr5_4
    radGr5_5
    radGr5_6
    radGr6_1
    radGr6_2
    radGr6_3
    radGr6_4
    radGr6_5
    radGr6_6
    Those listed with “radGr1” are in the first group box labeled grpST, “radGr2” are in the second group box labeled grpDX, and so on (grpCN, grpIQ, grpWS, grpCH). What I want the code to do is change the labels of the radio buttons so that the text displayed
    in everything with a suffix of “_1” is filled with the first number in the selected listbox. For example, if I select the first list box, the other 2 are cleared and only the 6 numbers in the first one are used for the rest of the program. If those numbers
    are 12, 13, 14, 15, 17, and 11, then everything with _1 at the end should have “12”, everything with _2 should have “13”, and so on. What I don’t want to have to do is initialize 36 elements, then have 6 different selections for each group box. I tried to
    attach an image, but it wouldn’t let me…something about verifying my account or something…
    Can I suggest a different layout?  It seems like the status selection process is over-complicating the code... please consider this form layout:
    Once the user has selected the set of rolls they want you use, you can then just work with that single listbox.  The radio buttons let them select a particular stat and the listbox lets them select a value.  The "<-" button then assigns
    the selected value to the selected stat, and removes it from the listbox.  The "->" button clears the selected stat and returns the value to the listbox.  The code is something like:
    Public Class Form1
    Private Sub SetButton_Click(sender As Object, e As EventArgs) Handles SetButton.Click
    If ChosenRollsListBox.SelectedIndex > -1 Then
    Select Case True
    Case StrRadioButton.Checked
    If Not StrLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(StrLabel.Text)
    End If
    StrLabel.Text = ChosenRollsListBox.SelectedItem.ToString
    ChosenRollsListBox.Items.RemoveAt(ChosenRollsListBox.SelectedIndex)
    Case DexRadioButton.Checked
    If Not DexLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(DexLabel.Text)
    End If
    DexLabel.Text = ChosenRollsListBox.SelectedItem.ToString
    ChosenRollsListBox.Items.RemoveAt(ChosenRollsListBox.SelectedIndex)
    Case ConRadioButton.Checked
    If Not ConLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(ConLabel.Text)
    End If
    ConLabel.Text = ChosenRollsListBox.SelectedItem.ToString
    ChosenRollsListBox.Items.RemoveAt(ChosenRollsListBox.SelectedIndex)
    Case IntRadioButton.Checked
    If Not IntLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(IntLabel.Text)
    End If
    IntLabel.Text = ChosenRollsListBox.SelectedItem.ToString
    ChosenRollsListBox.Items.RemoveAt(ChosenRollsListBox.SelectedIndex)
    Case WisRadioButton.Checked
    If Not WisLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(WisLabel.Text)
    End If
    WisLabel.Text = ChosenRollsListBox.SelectedItem.ToString
    ChosenRollsListBox.Items.RemoveAt(ChosenRollsListBox.SelectedIndex)
    Case ChaRadioButton.Checked
    If Not ChaLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(ChaLabel.Text)
    End If
    ChaLabel.Text = ChosenRollsListBox.SelectedItem.ToString
    ChosenRollsListBox.Items.RemoveAt(ChosenRollsListBox.SelectedIndex)
    End Select
    End If
    End Sub
    Private Sub ClearButton_Click(sender As Object, e As EventArgs) Handles ClearButton.Click
    Select Case True
    Case StrRadioButton.Checked
    If Not StrLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(StrLabel.Text)
    StrLabel.Text = "_"
    End If
    Case DexRadioButton.Checked
    If Not DexLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(DexLabel.Text)
    DexLabel.Text = "_"
    End If
    Case ConRadioButton.Checked
    If Not ConLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(ConLabel.Text)
    ConLabel.Text = "_"
    End If
    Case IntRadioButton.Checked
    If Not IntLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(IntLabel.Text)
    IntLabel.Text = "_"
    End If
    Case WisRadioButton.Checked
    If Not WisLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(WisLabel.Text)
    WisLabel.Text = "_"
    End If
    Case ChaRadioButton.Checked
    If Not ChaLabel.Text = "_" Then
    ChosenRollsListBox.Items.Add(ChaLabel.Text)
    ChaLabel.Text = "_"
    End If
    End Select
    End Sub
    End Class
    This may not suit your requirements but I thought it was at least worth considering an alternate design that would be much easier to implement.
    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

  • JArray of Radio Buttons

    How do you set up an array of radio buttons? I have tried
    JRadioButton[] choiceButtons = new JRadioButton[40];
    for(int i=0; i < 40; i++) {
    choiceButtons= new JRadioButton();
    But this does not seem to work.
    Thanks in Advance.

    How do you set up an array of radio buttons? I have
    tried
    JRadioButton[] choiceButtons = new JRadioButton[40];
    for(int i=0; i < 40; i++) {
    choiceButtons= new JRadioButton();
    But this does not seem to work.
    Thanks in Advance.
    Try this.
    JRadioButton[] choiceButtons = new JRadioButton[40];
    for(int i=0; i < 40; i++) {
    choiceButtons= new JRadioButton("Lit for Button");

  • Run time change # of radio button and boolean text

    does Labview 8 support run time programmically change number of radio button and boolean text for each radio button?
    Thanks,
    DG

    You can also customize a slide control to look like radio buttons. You can control the text labels and the number of element through a property (by changing the scale properties). If you really want it to look like radio buttons, you can try ripping the images from the dialog radio button. Also, to save some time, you can get the OpenG buttons package, which includes a slide customized to look like radio buttons. The main problem with this is that changing the number of items does not change the size of the control and that makes the dot filling the radio buttons look compressed.
    Another option is to create an array of radio buttons, but then you will have to handle the logic yourself.
    Try to take over the world!

  • Insert String array as label content in datagrid row through radio button C# wpf?

    I have written some code for inserting label at runtime having its content set to a string array and then insert that label into a datagrid row . All of this will initiate when certain radiobuttons are checked. code is working perfectly fine. But i need
    to improve this code as i am learning C#, wpf and datagrid. I know there can be a certain way to improve this code. 
    This code will be a nightmare when there are 50 radiobuttons. 
    can it be improve and how it can be? if u can explain that will be very kind of you  
    Xaml Code:
    <Grid>
    <RadioButton x:Name="rb_1" Content="RadioButton" HorizontalAlignment="Left" Margin="351,85,0,0" VerticalAlignment="Top" GroupName="1" />
    <RadioButton x:Name="rb_2" Content="RadioButton" HorizontalAlignment="Left" Margin="351,105,0,0" VerticalAlignment="Top" GroupName="1"/>
    <RadioButton x:Name="rb_3" Content="RadioButton" HorizontalAlignment="Left" Margin="351,120,0,0" VerticalAlignment="Top" GroupName="1" />
    <RadioButton Content="RadioButton" HorizontalAlignment="Left" Margin="351,159,0,0" VerticalAlignment="Top" GroupName="2" />
    <RadioButton x:Name="rb_4" Content="RadioButton" HorizontalAlignment="Left" Margin="351,179,0,0" VerticalAlignment="Top" GroupName="2"/>
    <RadioButton Content="RadioButton" HorizontalAlignment="Left" Margin="351,199,0,0" VerticalAlignment="Top" GroupName="2" />
    <Button Content="Button" HorizontalAlignment="Left" Margin="713,60,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_2"/>
    <DataGrid x:Name="datagrid_" HorizontalAlignment="Left" Margin="549,85,0,0" VerticalAlignment="Top" Height="253" Width="399" />
    <RadioButton Content="RadioButton" HorizontalAlignment="Left" Margin="351,226,0,0" VerticalAlignment="Top" GroupName="3" />
    <RadioButton x:Name="rb_6" Content="RadioButton" HorizontalAlignment="Left" Margin="351,246,0,0" VerticalAlignment="Top" GroupName="3"/>
    <RadioButton Content="RadioButton" HorizontalAlignment="Left" Margin="351,266,0,0" VerticalAlignment="Top" GroupName="3" />
    <RadioButton Content="RadioButton" HorizontalAlignment="Left" Margin="351,298,0,0" VerticalAlignment="Top" GroupName="4" />
    <RadioButton x:Name="rb_8" Content="RadioButton" HorizontalAlignment="Left" Margin="351,318,0,0" VerticalAlignment="Top" GroupName="4"/>
    <RadioButton Content="RadioButton" HorizontalAlignment="Left" Margin="351,338,0,0" VerticalAlignment="Top" GroupName="4" />
    </Grid>
    Code Behind:
    public partial class MainWindow : Window
    public MainWindow()
    InitializeComponent();
    DataTable dt;
    DataRow dr;
    string[] str = new string[4];
    int location = 0;
    int count = 0;
    private void Window_Loaded(object sender, RoutedEventArgs e)
    dt = new DataTable("emp");
    DataColumn dc1 = new DataColumn("Factors", typeof(string));
    DataColumn dc2 = new DataColumn("Non_Compliant", typeof(string));
    dt.Columns.Add(dc1);
    dt.Columns.Add(dc2);
    datagrid_.ItemsSource = dt.DefaultView;
    private void Button_Click_2(object sender, RoutedEventArgs e)
    if (count >= 1)
    datagrid_.ItemsSource = dt.DefaultView;
    dt.Clear();
    str[0] = "Load Path1";
    str[1] = "Load Path2";
    str[2] = "Load Path3";
    str[3] = "Load Path4";
    int j = 0;
    if (rb_2.IsChecked == true)
    j = 0;
    int k = 0;
    dr = dt.NewRow();
    Label label = new Label();
    label.Height = 28;
    label.Width = 100;
    label.HorizontalAlignment = HorizontalAlignment.Center;
    label.VerticalAlignment = VerticalAlignment.Center;
    label.Content = str[j];
    dr[k] = label.Content;
    dt.Rows.Add(dr);
    datagrid_.ItemsSource = dt.DefaultView;
    location += 34;
    if (rb_4.IsChecked == true)
    j = 1;
    int k = 0;
    dr = dt.NewRow();
    Label label = new Label();
    label.Height = 28;
    label.Width = 100;
    label.HorizontalAlignment = HorizontalAlignment.Center;
    label.VerticalAlignment = VerticalAlignment.Center;
    label.Content = str[j];
    dr[k] = label.Content;
    dt.Rows.Add(dr);
    datagrid_.ItemsSource = dt.DefaultView;
    location += 34;
    if (rb_6.IsChecked == true)
    j = 2;
    int k = 0;
    dr = dt.NewRow();
    Label label = new Label();
    label.Height = 28;
    label.Width = 100;
    label.HorizontalAlignment = HorizontalAlignment.Center;
    label.VerticalAlignment = VerticalAlignment.Center;
    label.Content = str[j];
    dr[k] = label.Content;
    dt.Rows.Add(dr);
    datagrid_.ItemsSource = dt.DefaultView;
    location += 34;
    if (rb_8.IsChecked == true)
    j = 3;
    int k = 0;
    dr = dt.NewRow();
    Label label = new Label();
    label.Height = 28;
    label.Width = 100;
    label.HorizontalAlignment = HorizontalAlignment.Center;
    label.VerticalAlignment = VerticalAlignment.Center;
    label.Content = str[j];
    dr[k] = label.Content;
    dt.Rows.Add(dr);
    datagrid_.ItemsSource = dt.DefaultView;
    location += 34;
    count++;

    @Usamakhan1990,
    Use usercontrol with label and checkbox is reasonable for a datagrid control if you don't want to have too much code for those radio buttons. So I agree with andy here with that usercontrol.
    So is it required that your radiobutton should be outside the datagrid?
    Anyway, I think you already know that you can bind data to columns yourself. So please check the following thread:
    http://stackoverflow.com/questions/22922533/how-do-i-automagically-bind-a-string-array-to-a-wpf-datagrid
    <DataGrid Name="_dataGrid" Grid.Row="0" AutoGenerateColumns="False">
    <DataGrid.Columns>
    <DataGridTextColumn Header="Column 1" Binding="{Binding [0]}"/>
    <DataGridTextColumn Header="Column 2" Binding="{Binding [1]}"/>
    </DataGrid.Columns>
    </DataGrid>
    Or define the columns from code, in case you have dynamic number of columns, for example :
    string[][] array = fs.CSVToStringArray();
    for (int i = 0; i < array[0].Length; i++)
    var col = new DataGridTextColumn();
    col.Header = "Column " + i;
    col.Binding = new Binding(string.Format("[{0}]", i));
    _dataGrid.Columns.Add(col);
    this.ExternalData._dataGrid.ItemsSource = array;
    And for Radio button part, please see here:
    http://stackoverflow.com/questions/397556/how-to-bind-radiobuttons-to-an-enum
    Best regards,
    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to increment array that contains two clusters whose visibility is controlled by a visible property node and selected by a radio button.

    I am trying to use a property node: visible in order to enable or disable one of two clusters. These clusters are in a larger cluster and this larger cluster is in an array. The two clusters are controlled by a radio button (one labeled transistor and the other diode). When diode is selected, the corresponding diode parameters cluster should be visible and when transistor is selected, the corresponding transistor parameters cluster should be visible. In the mean time, the cluster of the device that is not selected should not be visible. There are at least 45 elements in the array (but not more than 45). Data is entered into each cluster (diode or transistor data) for each element in the array via the increment/decrement. The problem is when you select the first radio button (transistor) and enter data, when you increment the array for a new device selection, since a visible property node was used on the cluster, a loop is created where a new cluster is trying to be shown, but the old cluster is also trying to be shown (because it is the one referenced by the property node. How do I get rid of this loop and still be able to increment the array and keep my data intact for future use? Attached is the vi
    Attachments:
    ChooseScan.vi ‏17 KB

    You could try something like this.  However, if you know how to use an xcontrol, that would be a better way to implement the above functionality so that these UI characteristics are not a part of your main VI.  The problem with the above VI is that you're looping every 100 ms just to update your UI.
    Also, try using the "disabled" property node, instead of the "visible" one.  That way, the user will still see the options he has but they will be grayed out.
    Message Edited by Sudhir Gopinath on 06-25-2007 04:45 PM
    S G
    Certified LabVIEW Architect, Certified TestStand Developer, Certified Professional Instructor
    Attachments:
    ChooseScan_1.vi ‏19 KB

  • Values of checkboxes and radio buttons not recognised

    Hi folks,
    I have a bit of a strange problem and I'm hoping you can help shed some light.
    Basically I have a form with various elements in it, some of which seem to have a problem telling my pl/sql code what their values are. The culprits seem to be radio buttons and check boxes. Now those are individual items created with the wizard within a specific section if the outcome is different from sql created form elements in tables.
    The radio buttons is one field, let's call it :P100_RADIO which returns either 'AB', 'CD' or 'EF'. The checkbox, let's call it :P100_CHECKBOX is just one checkbox returning the value 'Y' if it's checked.
    after submit, I have a process which among other things checks the value returned by those two elements to set a variable v_paid either as 'Y' or 'N'
    as a small summary of what I'm trying to do, here's a code snippet:
    v_checkbox varchar2(1);
    v_paid varchar2(1);
    begin
    v_checkbox := :P100_CHECKBOX;
    if v_checkbox is not null AND :P100_RADIO = 'CD' THEN
      v_paid := 'Y';
    else
      v_paid := 'N';
    end if;
    end;If I submit my form I get the error message
    "ORA-06502: PL/SQL: numeric or value error: character to number conversion error"If I change the condition to v_checkbox is not null only, I get the same error
    If I change it to v_checkbox != '' I don't get an error but v_paid is set with 'N'
    If I change it to v_checkbox = 'Y', I get the same error again
    If I change it to *:P100_RADIO = 'CD'* only, I get the error as well.
    I also mistakenly tried v_checkbox is null and it submitted fine, though the value of v_paid was still 'N'
    I've tried changing the varchar2(1) to something greater, up to varchar2(4000) but that didn't make any difference.
    So I seem to understand there's a discrepancy of types somewhere but I can't work out where or how to change that. In my code an insert is performed after the if statement and the value of :P100_RADIO is added to the table with the expected value.
    After looking at the source of the page produced by Apex, I also tried to replace :P100_CHECKBOX with :P100_CHECKBOX_0 but that didn't make a difference either. It's possible Apex thinks :P100_RADIO and :P100_CHECKBOX are supposed to return some sort of arrays but just why it would just return a string in an sql statement beats me.
    The worst thing is, I'm fairly certain the code worked the first time I implemented it. So if anyone has any idea of what's going on that would be quite helpful. As always, I have a nagging suspicion it's a silly tiny mistake somewhere I just can't see.
    Thanks folks :)

    okay here's the code for the whole procedure. Some variable names have been changed but it's otherwise the same code:
    DECLARE
    v_total_cost     NUMBER(10,2);
    v_deposit        NUMBER(10,2);
    v_remaining      NUMBER(10,2);
    v_payment_type   varchar2(2);
    v_checkbox       varchar2(4000);
    v_user           varchar2(4000);
    v_bok_paid       varchar2(1);
    v_msg            varchar2(4000);
    BEGIN
    v_total_cost     := :P100_COST;
    v_deposit        := :P100_DEPOSIT;
    v_remaining      := v_total_cost - v_deposit;
    v_payment_type   := :P100_PAYMENT_AMOUNT;
    v_checkbox       := :P100_CHECKBOX;
    v_user           := :APP_USER;
    --wwv_flow.debug('before condition');
    if v_checkbox != '' AND :P100_RADIO = 'CD' THEN
      v_bok_paid := 'Y';
    else
      v_bok_paid := 'N';
    end if;
    --wwv_flow.debug('after condition');
    IF v_payment_type  = 'D' THEN
    :P100_AMOUNT_TO_PAY := :P100_DEPOSIT;
    INSERT INTO SAL_TRANSACTIONS (TRA_BKG_ID, TRA_COST, TRA_TOTAL,TRA_TYPE, TRA_PAID, TRA_PAY_TYPE, TRA_DATE, TRA_MANUAL, TRA_USER)
    VALUES (:P100_BKG_ID, 0, v_deposit, v_payment_type, v_bok_paid, :P100_RADIO, SYSDATE, v_checkbox, v_user);
    INSERT INTO SAL_TRANSACTIONS (TRA_BKG_ID, TRA_COST, TRA_TOTAL,TRA_TYPE, TRA_PAID, TRA_PAY_TYPE, TRA_DATE, TRA_MANUAL, TRA_USER)
    VALUES (:P100_BKG_ID, 0, v_remaining, 'L','N', null, SYSDATE, v_checkbox, v_user);  
    ELSIF v_payment_type  = 'F' THEN
    :P100_AMOUNT_TO_PAY := :P100_COST;
    INSERT INTO SAL_TRANSACTIONS (TRA_BKG_ID, TRA_COST, TRA_TOTAL,TRA_TYPE, TRA_PAID, TRA_PAY_TYPE, TRA_DATE, TRA_MANUAL, TRA_USER)
    VALUES (:P100_BKG_ID, 0, v_total_cost, :P100_PAYMENT_AMOUNT, v_bok_paid, :P100_RADIO, SYSDATE, v_checkbox, v_user);
    END IF;
    :P100_TRANSACTION_FLAG := '1';
    if v_bok_paid = 'Y' then
    v_msg := '<div>Message clipped</div>';
    --send confirmation email
    GLO_CORRESPONDANCE.proc_corr_controller(
    :P100_BOOKING_MEMBER_ID,
    :P100_BKG_ID,
    null,
    v_msg,
    'E',
    'Payment confirmation',
    null
    end if;
    END;Thanks :)

  • Radio Buttons w/ Multiple Values on a PHP Form

    Hi,
    I have an Online Registration form with several options that each have their own prices.  I want the form results to show the name of each option the user selects, and the total of all the prices combined.  My question is how can I do that when each radio button only allows you to attach one value?  Is there a way to somehow retrieve the option name and price as two separate values?
    <input name="option" type="radio" value="Cotton - $10" />
    <input name="option" type="radio" value="Suede - $15" />
    <input name="option" type="radio" value="Leather - Black - $20" />
    <input name="option" type="radio" value="Leather - White - $20" />
    For example, if they select 'Leather - Black - $20" I want to be able to retrieve one value of "Leather - Black" and another value of "20.00" (to add to the total price) rather than simply "Leather - Black - $20" in one value.
    Any help would be greatly appreciated!  I've only had to deal with one value for each radio button in the past.
    Thanks!
    Paul

    Yes you can do this.  If I were you I would eliminate the space in the value just to eliminate confusion.  Then when you process the variable use the Explode function ( http://php.net/manual/en/function.explode.php ) to separate the values in your string.  So if you eliminate the space your code would look like:
    $_POST['option'] = $option;
    $option = explode ("-",$option);
    print $option[0]; //This would print the material
    print $option[1]; //This would print the price
    The only trick is your first two options don't have a color.  So your arrays would be different.  To offset this I would recommend that you use the same format for all options and make some sort of null value if nothing will be added for one value in the array, ie: color.

  • How do I disable one item in a radio buttons control at run time

    I need to disable one item in a radio buttons control. At design time
    this is possible, but how do I do this at run time? Is this possible? I
    cannot find a property per item

    Use the property "Controls[ ]" - this gives you an array with references of each single button in the radio buttons control. These you can access with property nodes too.
    Hope this helps.
    Using LV8.0
    Don't be afraid to rate a good answer...

  • Print multiple page ranges based on radio button group choices

    Hi ... I have a PDF that is a combined application form made up of 6 separate forms. On the front page, I have 6 groups of "Yes / No" radio buttons.
    If the radio button for one or more of these groups is selected as "Yes" then when the Print button (on the page) is clicked then the appropriate page ranges will print.
    It is desireable, though not essential, for these to be printed in one print job.
    The Code I have been adjusting to try and achieve the result is below but I have tied myself in knots now and any help would be greatly appreciated:
    Many thanks
    //<AcroForm>
    //<ACRO_source>PrntForms:Annot1:MouseUp:Action1</ACRO_source>
    //<ACRO_script>
    /*********** belongs to: AcroForm:PrntForms:Annot1:MouseUp:Action1 ***********/
    var nButton = app.alert({
    cMsg: "Your selected forms will be sent to your default printer.\n\nIf you require to print to an alternative printer, press cancel and select 'Print' from the 'File' menu.",
    cTitle: "Submit Forms for Printing?",
    nIcon: 1, nType: 1
    // array for button responses
    //var aResponse = new Array("OK", "Cancel");
    if(nButton == 1)
    {    this.print({ bUI: false, bSilent: true, bShrinkToFit: true, nStart: 1, nEnd: 1 });
    } else
    if(nButton == 0)
    {    this.Exit
    var a_app;
    if(this.getField("AppForm1”).value=="Yes"){
        a_app = "1, 1";
    } else a_app = "0, 0"
    var b_app;
    if(this.getField(“AppForm2”).value=="Yes"){
        b_app = "2, 2";
    } else b_app = "0, 0"
        var pp = this.getPrintParams();
              pp.interactive = pp.constants.interactionLevel.full;
              pp.printRange=[[a_app], [b_app]];
              this.print(pp);
    //</ACRO_script>
    //</AcroForm>

    Hi Gilad D
    The 'printRanges.push' function works well on my Mac using Adobe Acrobat Pro XI however when it is used on the systems that the form users will be working on (which runs Adobe Reader 9.4.0.195) the ranges are not pushed to the printer dialogue box and the 'printRange'
    in the dialogue is still selecting the 'All Pages' radio button.
    Is the printRanges.push function a new and non-backwards-compatible function or is my code the problem
    //<AcroForm>
    //<ACRO_source>PrntForms:Annot1:MouseUp:Action1</ACRO_source>
    //<ACRO_script>
    /*********** belongs to: AcroForm:PrntForms:Annot1:MouseUp:Action1 ***********/
    var printRanges = [];
    if (this.getField("RBG10").value=="Yes") printRanges.push([0,2]);
    if (this.getField("RBG1").value=="Yes") printRanges.push([3,18]);
    if (this.getField("RBG2").value=="Yes") printRanges.push([19,27]);
    if (this.getField("RBG3").value=="Yes") printRanges.push([28,38]);
    if (this.getField("RBG4").value=="Yes") printRanges.push([39,42]);
    if (this.getField("RBG5").value=="Yes") printRanges.push([43,54]);
    if (this.getField("RBG6").value=="Yes") printRanges.push([14,16]);
    if (this.getField("RBG7").value=="Yes") printRanges.push([55,56]);
    if (this.getField("RBG8").value=="Yes") printRanges.push([57,65]);
    if (this.getField("RBG9").value=="Yes") printRanges.push([66,71]);
    if(printRanges.length>0){
       var pp = this.getPrintParams();
                pp.interactive = pp.constants.interactionLevel.full;
                pp.printRange=printRanges;
                this.print(pp);
    }else app.alert("No page ranges are selected");
    //</ACRO_script>
    //</AcroForm>
    Any assistance is greatly appreciated.
    Many thanks

  • Please help! How can I validate Radio Buttons and List Menu with PHP.

    Hello everyone, I have been learning PHP step by step and
    making little projects.
    The point is I find it easy to learn by doing "practical
    projects."
    I have been reading the David Powers's Book on PHP Solutions
    and it's really great, however there is nothing mentioned regarding
    Validating Radio buttons. I know the book cannot cover every aspect
    of PHP and maybe someone in here can help.
    I have been learning how to process HTML forms with PHP.
    The problem is every book or tutorial I have read or
    encountered fall short on validation.
    I'm wondering how I can learn to validate Radio Buttons and
    Select List Menu.
    I have managed to create validation for all other fields but
    have no clue as to how I can get validation for Radio Buttons and
    List Menu.
    I would also like an error message echoed when the user does
    not click a button or make a selection and try to submit the form.
    I would appreciate any help.
    Patrick

    It's not that default value is "None." In fact it's not. It
    will only be
    "none" when the form is submitted.
    Also if your submit button is names 'send' then
    $_POST['send'] will only be
    set if the form was submitted.
    Make sure you didn't hit the refresh button on your browser
    which usually
    reposts the information. Also make sure you did not reach the
    form from
    another form with the same button names.
    Otherwise paste the snippet.
    Also you can check what fields are set in the post array by
    adding this to
    the top of (or anywhere on) your page:
    print_r($_POST);
    Cosmo
    "Webethics" <[email protected]> wrote in
    message
    news:[email protected]...
    >
    quote:
    Originally posted by:
    Newsgroup User
    > Off the top of my head this should be no different than
    your radio buttons
    > except that 'productSelection' will always fail the
    !isset check when the
    > form is submitted since the default value is "None", and
    therefore always
    > set. :-)
    >
    > So how about this..?
    > <?php
    > if (isset($_POST['send']) and
    ($_POST['productSelection'] == "None"))
    > {echo "Please select a product.";}
    > ?>
    >
    >
    >
    >
    > "Webethics" <[email protected]> wrote
    in message
    > news:[email protected]...
    > > Another question - how do i applied the code you
    just showed me to
    > > select
    > > menu
    > > or select list?
    > >
    > > This is the list:
    > >
    > > <div class="problemProduct">
    > > <label for="productSelection"><span
    class="product_label">Product
    > > Name.</span></label>
    > > <select name="productSelection" id="products"
    class="selection">
    > > <option value="None">-------------Select a
    product----------</option>
    > > <option value="Everex DVD Burner">Everex DVD
    Burner</option>
    > > <option value="Vidia DVD Burner">Vidia DVD
    Burner</option>
    > > <option value="Excerion Super Drive">Excerion
    Super Drive</option>
    > > <option value="Maxille Optical Multi
    Burner">Maxille Optical Multi
    > > Burner</option>
    > > <option value="Pavilion HD Drives">Pavilion
    HD Drives</option>
    > > </select>
    > > </div>
    > >
    > > I thought I could just change the name is the code
    from operatingSystem
    > > to
    > > productSelection.
    > >
    > > Something like this:
    > >
    > > From this:
    > >
    > > <?php
    > > if (isset($_POST[send]) and
    !isset($_POST['operatingSystem']))
    > > {echo "Please select an operating system.";}
    > > ?>
    > >
    > > To this:
    > >
    > > <?php
    > > if (isset($_POST[send]) and
    !isset($_POST['productSelection']))
    > > {echo "Please select an operating system.";}
    > > ?>
    > >
    > > But this does not work, any ideas?
    > >
    > > Patrick
    > >
    >
    >
    >
    >
    > Hey, I tried this about but as you mentioned, since the
    default product
    > value
    > is "None" an error message appears when the page loads.
    >
    > Is there a way to code this things so that even though
    the default value
    > is
    > "None" there ia no error message untle you hit the
    submit?
    >
    > When I applied the code, it messes up the previous code,
    now the operating
    > system is requiring an entry on page load.
    >
    > When I remove the code from the list menu everything
    goes back to normal.
    >
    > I know this is a little much but I have no other
    alternatives.
    >
    > Patrick
    >

  • Radio buttons - text format

    Hi everyone!
    I can't seem to get this to work! I want the text on the radio buttons to wrap correctly as they reach the end of the stage (right now they just keep going forever. Here is the code I am using:
    package {
        import flash.display.MovieClip;
        import flash.text.TextField;
        import flash.text.TextFormat;
        import flash.text.TextFieldAutoSize;
        import flash.events.Event;
        import fl.controls.RadioButton;
        import fl.controls.RadioButtonGroup;
        public class QuizQuestion extends MovieClip {
            private var question:String;
            private var questionField:TextField;
            private var choices:Array;
            private var theCorrectAnswer:int;
            private var theUserAnswer:int;
            //variables for positioning:
            private var questionX:int = 25;
            private var questionY:int = 150;
            private var answerX:int = 25;
            private var answerY:int = 200;
            private var spacing:int = 25;
            public function QuizQuestion(theQuestion:String, theAnswer:int, ...answers) {
                //store the supplied arguments in the private variables:
                question = theQuestion;
                theCorrectAnswer = theAnswer;
                choices = answers;
                //create and position the textfield (question):
                questionField = new TextField();
                questionField.width = 775;
                questionField.wordWrap = true;
                questionField.multiline = true;
                questionField.text = question;
                //trace (questionField.width);
                questionField.autoSize = TextFieldAutoSize.LEFT;
                questionField.x = questionX;
                questionField.y = questionY;
                addChild(questionField);
                //Text Format for radio buttons
                var txtFmt:TextFormat = new TextFormat();
                txtFmt.font = "Arial";
                txtFmt.blockIndent = 2;
                txtFmt.color = 0x000000;
                txtFmt.size = 11;
                txtFmt.leading = 4;
                //create and position the radio buttons (answers):
                var myGroup:RadioButtonGroup = new RadioButtonGroup("group1");
                myGroup.addEventListener(Event.CHANGE, changeHandler);
                for(var i:int = 0; i < choices.length; i++) {
                    var rb:RadioButton = new RadioButton();
                    rb.setStyle("textFormat", txtFmt);
                    rb.textField.autoSize = TextFieldAutoSize.LEFT;
                    rb.label = choices[i];
                    rb.group = myGroup;
                    rb.value = i + 1;
                    rb.x = answerX;
                    rb.y = questionY + questionField.height + 25 + (i * spacing);
                    addChild(rb);
            private function changeHandler(event:Event) {
                theUserAnswer = event.target.selectedData;
            public function get correctAnswer():int {
                return theCorrectAnswer;
            public function get userAnswer():int {
                return theUserAnswer;
    As you can see, I managed to get the text field style of the radio buttons to use "txtFmt" as the style:
    rb.setStyle("textFormat", txtFmt);
    The issue:
    If I add:
    rb.textField.width = 352;
    rb.textField.height = 60;
    rb.textField.multiline = rb.textField.wordWrap = true;
    inside the "for loop" that creates the radio button, it just makes my text go all crazy! It only extends the text about 30 pixels after the radio button and then starts wrapping it, making it all stack on top of each other. How can I make it create the radio button, show the text on the text field, wrap around once it reached the edge of the stage and the continue the next button.
    thank you in advanced,
    Rafa.

    Kglad,
    I added the trace command to the 1st frame of my FLA, and it shows the "test" message on the output window.
    I am looking thru my code, but can't figure what could be overwritting it. This is what I have on the first AS file:
    package {
        import flash.display.MovieClip;
        import flash.text.TextField;
         import flash.text.TextFormat;
        import flash.text.TextFieldAutoSize;
        import flash.events.Event;
        import fl.controls.RadioButton;
        import fl.controls.RadioButtonGroup;
        public class QuizQuestion extends MovieClip {
            private var question:String;
            private var questionField:TextField;
            private var choices:Array;
            private var theCorrectAnswer:int;
            private var theUserAnswer:int;
            //variables for positioning:
            private var questionX:int = 25;
            private var questionY:int = 150;
            private var answerX:int = 25;
            private var answerY:int = 200;
            private var spacing:int = 25;
            public function QuizQuestion(whichQuestion:int, theQuestion:String, theAnswer:int, ...answers) {
                //store the supplied arguments in the private variables:
                question = theQuestion;
                theCorrectAnswer = theAnswer;
                choices = answers;
                   //Text Format for readio buttons
                   var txtFmt:TextFormat = new TextFormat();
                   txtFmt.font = "Arial";
                   txtFmt.blockIndent = 2;
                   txtFmt.color = 0x000000;
                   txtFmt.size = 12;
                   txtFmt.leading = 4;
                //create and position the textfield (question):
                questionField = new TextField();
                questionField.width = 770;
                   questionField.wordWrap = true;
                   questionField.multiline = true;
                   questionField.text = question;
                   //trace (questionField.width);
                questionField.autoSize = TextFieldAutoSize.LEFT;
                questionField.x = questionX;
                questionField.y = questionY;
                   questionField.setTextFormat(txtFmt);
                addChild(questionField);
                //create and position the radio buttons (answers):
                var myGroup:RadioButtonGroup = new RadioButtonGroup("group1");
                myGroup.addEventListener(Event.CHANGE, changeHandler);
                var rbY:Number = 100;
                   for(var i:int = 0; i < choices.length; i++) {
                    var rb:RadioButton = new RadioButton();
                    rb.setStyle("textFormat", txtFmt);
                    rb.textField.width = 352;
                    rb.textField.autoSize = "left";
                    rb.textField.multiline  = rb.textField.wordWrap = true;
                    rb.textField.autoSize = TextFieldAutoSize.LEFT;
                    rb.label = choices[i];
                    rb.group = myGroup;
                    rb.value = i + 1;
                    rb.x = 300;
                    rb.y = rbY;
                    rbY = rb.y+rb.height;
                    addChild(rb);
            private function changeHandler(event:Event) {
                theUserAnswer = event.target.selectedData;
            public function get correctAnswer():int {
                return theCorrectAnswer;
            public function get userAnswer():int {
                return theUserAnswer;
    This is the AS that creates the questions:
    package {
        import flash.display.MovieClip;
        import fl.controls.Button;
        import flash.events.MouseEvent;
        import flash.text.TextField;
        import flash.text.TextFieldAutoSize;
        public class QuizApp extends MovieClip {
            //for managing questions:
            private var quizQuestions:Array;
            private var currentQuestion:QuizQuestion;
            private var currentIndex:int = 0;
            //the buttons:
            private var prevButton:Button;
            private var nextButton:Button;
            private var finishButton:Button;
            //scoring and messages:
            private var score:int = 0;
            private var status:TextField;
            public function QuizApp() {
                quizQuestions = new Array();
                createQuestions();
                createButtons();
                createStatusBox();
                addAllQuestions();
                hideAllQuestions();
                firstQuestion();
            private function createQuestions() {
                quizQuestions.push(new QuizQuestion(1, "1. Which of the following statements about the government auditor’s use of audit standards is least accurate? ",
                                                                1,
                                                                "Government auditors may be subject to a variety or range of audit standards.",
                                                                "Government auditors are not subject to audit standards for some types of work.",
                                                                "If the audit organization follows The Institute of Internal Auditors’ (IIA’s) International Standards for the Professional Practice of Internal Auditing (Standards), those Standards prevail over laws and regulations.",
                                                                "Different sets of audit standards that might be followed have many similarities."));
            private function createButtons() {
                var yPosition:Number = stage.stageHeight - 125;
                prevButton = new Button();
                prevButton.label = "Previous";
                prevButton.x = 30;
                prevButton.y = yPosition;
                prevButton.addEventListener(MouseEvent.CLICK, prevHandler);
                addChild(prevButton);
                nextButton = new Button();
                nextButton.label = "Next";
                nextButton.x = prevButton.x + prevButton.width + 40;
                nextButton.y = yPosition;
                nextButton.addEventListener(MouseEvent.CLICK, nextHandler);
                addChild(nextButton);
                finishButton = new Button();
                finishButton.label = "Finish";
                finishButton.x = nextButton.x + nextButton.width + 40;
                finishButton.y = yPosition;
                finishButton.addEventListener(MouseEvent.CLICK, finishHandler);
                addChild(finishButton);
            private function createStatusBox() {
                status = new TextField();
                status.autoSize = TextFieldAutoSize.LEFT;
                status.y = stage.stageHeight - 80;
                addChild(status);
            private function showMessage(theMessage:String) {
                status.text = theMessage;
                   status.x = (stage.stageWidth / 5) - (status.width / 5);
            private function addAllQuestions() {
                for(var i:int = 0; i < quizQuestions.length; i++) {
                    addChild(quizQuestions[i]);
            private function hideAllQuestions() {
                for(var i:int = 0; i < quizQuestions.length; i++) {
                    quizQuestions[i].visible = false;
            private function firstQuestion() {
                currentQuestion = quizQuestions[0];
                currentQuestion.visible = true;
            private function prevHandler(event:MouseEvent) {
                showMessage("");
                if(currentIndex > 0) {
                    currentQuestion.visible = false;
                    currentIndex--;
                    currentQuestion = quizQuestions[currentIndex];
                    currentQuestion.visible = true;
                } else {
                    showMessage("This is the first question, there are no previous ones");
            private function nextHandler(event:MouseEvent) {
                showMessage("");
                   //This will not allow the user to continue forward unless they answer the current question
               /* if(currentQuestion.userAnswer == 0) {
                    showMessage("Please answer the current question before continuing");
                    return;
                if(currentIndex < (quizQuestions.length - 1)) {
                    currentQuestion.visible = false;
                    currentIndex++;
                    currentQuestion = quizQuestions[currentIndex];
                    currentQuestion.visible = true;
                } else {
                    showMessage("That's all the questions! Click Finish to Score, or Previous to go back");
            private function finishHandler(event:MouseEvent) {
                showMessage("");
                var finished:Boolean = true;
                for(var i:int = 0; i < quizQuestions.length; i++) {
                    if(quizQuestions[i].userAnswer == 0) {
                        finished = false;
                        break;
                if(finished) {
                    prevButton.visible = false;
                    nextButton.visible = false;
                    finishButton.visible = false;
                    hideAllQuestions();
                    computeScore();
                } else {
                    showMessage("You haven't answered all of the questions");
            private function computeScore() {
                for(var i:int = 0; i < quizQuestions.length; i++) {
                    if(quizQuestions[i].userAnswer == quizQuestions[i].correctAnswer) {
                        score++;
                showMessage("You answered " + score + " correct out of " + quizQuestions.length + " questions.");
    I also have a timer running on my FLA, but even if I comment out the timer, I still get the same issue.
    thank you for your help,
    Rafa.

  • Variable drop-down lists according to radio-button input

    I need to restrict the display of drop-down lists according to a particular radio-button selection earlier on the form. Can I use a javascript call on the client side without linking to an external database along these lines:
    If radiobutton1 == 1
    then dropdownlist1 uses list1
    elseif radiobutton1 == 2
    then dropdownlist1 uses list2
    and so forth.
    Obviously the syntax is incorrect, but I need to know if it can be done before digging in further.

    Let's assume we have tree grouped radio buttons in a group of buttons, and a combo box object which displays a different list of elements depending of the chosen option.
    A very simple way to do it would be, for example, the following one:
    b [*] Radio Button Group - OnClick Event
    i // List of elements that will be loaded in the combo box object
    > var colorList = new Array("White","Blue","Red","Green");
    > var dayList = new Array("Monday","Tuesday","Wednesday","Thursday");
    > var tmarkList = new Array("Nike","Adidas","Reebook","Levis");
    i // ComboBox Object
    > var combo = xfa.resolveNode("Formulario1.ComboBox");
    i // Cleaning the combo...
    > combo.clearItems();
    > combo.addItem("Select one option to the list","");
    i // Filling the Combo
    i // "this" returns a button group where there are three radio buttons
    i // and the "rawValue" returns the selected index chosen in radio
    i // buttons.
    > switch(this.rawValue)
    > {
    > case "1":
    > for(nJ = 0; nJ < colorList.length; nJ++)
    > combo.addItem(colorList[nJ]);
    > break;
    > case "2":
    > for(nJ = 0; nJ < dayList.length; nJ++)
    > combo.addItem(dayList[nJ]);
    > break;
    > case "3":
    > for(nJ = 0; nJ < tmarkList.length; nJ++)
    > combo.addItem(tmarkList[nJ]);
    > break;
    >}

  • Assign values dynamically to radio button

    I am creating an online test. I will need to display answer choices from the table. I created radio buttons for these answer choices and I could put the labels dynamically by using      
    Set_Radio_Button_Property('block_name.radio_group_name', 'radio_button1',LABEL,cursor_name.field_name);
    Now I have problem to set radio button values dynamically. Should I use when_radio_changed event?
    Any help would be appreciated.

    I really appreciate your help.
    My intention is to display the test on the screen.
    That means I need to display all questions and answer
    choices for each one dynamically. Based on the answer
    choice type (radio button or checkbox or drop down
    etc) I will need to assign the values to them and
    display on the screen. So far I could display
    questions and answer choices on the screen and set
    the label property for each radio button.
    Do you know what is the syntax to assign value to
    each radio button? First I will need to store user's
    answers in a table. For that I need to know what
    answer they selected. I wasn't sure how to do that.
    ThanksAs I said, the values cannot be assigned dynamically. Thus you will store the answers in code (perhaps in an array?) and your radio buttons will be 1,2,3,4 etc.
    In WHEN-RADIO-CHANGED you can retrieve the value from the array using the radio button value. Then store that value.
    e.g. Your screen shows
    What is the sound of one hand clapping?
    o Blue
    o Yes
    o 12
    These labels will be set dynamically, but the values for the radio buttons will be 1,2,3. If they pick "Yes", your radio button will be 2. You then get the value you really want from answer_array(2), where you put it when you retrieved the question details. Then you insert that into your users_answers table.

  • One pair of radio buttons to control multiple text objects - Designer 8.0

    Greetings - a big thank you in advance for any assistance. I have often found answers to my problems on this forum, but have been unable to find an answer to the following.
    The short of it - is it possible to make a pair of radio buttons control the visibility of multiple text objects with the same name(I have had success in manipulating only a single text object with one pair of buttons)?
    The long of it - I am trying to make a form bilingual based on the value of a radio button group to control the visibility of the text object in the selected language. When the user selects the language they wish to see, all the text objects in the form switch to that language. I am working with a dynamic PDF.
    I have succeeded to a very limited extent in manipulating one text object by overlaying text objects in both languages, setting one object to "invisible" as default, and controlling that text objects visibility with the following JavaScript in the click event of the radio button group:
    ----- form1.#subform[0].ENG_JPN::click: - (JavaScript, client) -------------------------------------
    if (ENG_JPN.rawValue == 1)///1 equals the value of on
    {English.presence = "visible";}
    else
    {English.presence = "invisible";}
    if (ENG_JPN.rawValue == 2)///2 equals the value of on
    {Japanese.presence = "visible";}
    else
    {Japanese.presence = "invisible";}
    endif
    The problem is I need to manipulate the visibility of all text objects with the same name on the form with a single radio button group. I have tried writing the code as one does for the sum of a repeating field, ie. English[*].presence etc. however I get a C++ error in preview.
    Any ideas are greatly appreciated. I am truly stumped - thank you for your time.

    To access objects with the same name you need to deal with occurance numbers. If your object is called TextField then the 1st occurance will be TextField[0], the second occurance will be TextField[1] etc.....
    The issue is that the [] in javascript are interpretted as an array element so you have to use the syntax: xfa.reolveNode("string") to get to your object names. In your case you would use:
    xfa.resolveNode("TextField[1]").presence = "visible"
    This string syntax allows you to use a var to hold the index number and is very useful with for loops where you want to set large numbers of objects. So if the index was held in the var i then your syntax would be:
    xfa.resolveNode("TextField[" + i + "]").presence = "visible"
    If the objects are in a repeating subform then the occurance numbers are on the subform and not the object. You can always get the expression to use by app.alert(objectname.somExpression). This will return the expression that you need to create.
    Make sense?

Maybe you are looking for