Association of radio buttons to table rows

Hi
I am using servlets to connect to a database and display it in the form of HTML table. I need to assign a radio button to each row. This table contains around 100 rows. THe radio button should be a column before "Name". How can I assign a radio button to each row without doing 100 times like
<input type=radio name="id" value="1"> <input type=radio name="id" value="2"> ...so on for each row because I am using result set to display the table.
                                              while(rs.next())
                                                out.println("<TR>");
                                                out.println("<TD>" + rs.getString("NAME") + "</TD>");
                                                out.println("<TD>" + rs.getString("PHONE") + "</TD>");
                                                out.println("<TD>" + rs.getString("ADDRESS") + "</TD>");
                                                out.println("<TD>" + rs.getString("ADDRESS") + "</TD>");
                                                out.println("</TR>");
                                              ex table:
                                              Name  Phone  Address   State
                                              asd    asd     dasd     dasd
                                              sada   dasd    dasd     sadas
                                              sda    dasd    sadas    dasd
                      Any help would be greatly appreciated
Thanks

You could do it in a loop...
for (int i = 0; i < 100; i++) {
<input type=radio name="id" value="<%=i%>">
Hope this helps!

Similar Messages

  • How do you bind a radio button to a row in a table

    Im developing a web page that does a search given certain criteria. It displays the results in a table and dynamically allocates a radio button for each row that is created.
    I then want to be able to select the radio() button and display the row that was selected by the radio button on another page.
    Im doing a project in college developing a online airline ticket booking system. The user searches for flights and is displayed back with the Outgoing flights and the return flights. Each flight that is displayed is given a radio button. The problem is that I want to let the user select the a radio button that corresponds with their choice of flight and display this flight on the next page.
    Can anyone help me please with some code or ideas on how to go about doing it
    Thanks very much Nicky

    I suppose you do something like this:
    <sql:query var="var" scope="request">
    SELECT * FROM table
    WHERE something = ?
    <sql:param value="${param.something}" />
    Right??
    When you start the page, add:
    <%@ page language="java" %>
    Then under that
    <% int i = 0; %>
    Then:
    <html>
    <body>
    <form action="your_action" method="post">
    <table>
    <c:forEach items="${var.rows}" var="v">
    <% i++; %>
    <tr>
    <td>
    <input type="radio" name="yourname<%= i %>" value="yourvalue">
    </td>
    </tr>
    </c:forEach>
    <tr>
    <td>
    <input type="Hidden" name="i" value="<%= i %>">
    <input type="Submit value="next page">
    etc. etc.
    Follow me so far?

  • Two radio button in each row of Table view

    Hi,
    I have a issue like two radio button should come in each row of the tableview and any one only can be selected and selected value should be assigned to a variable.
    Kindly help with coding in methods RENDOR_CELL_START AND RENDER_ROW_START.
    Thanks in Advance.
    Saravanan.

    Saravanan,
    If you keep the Radiobutton in 2 different column then it wil difficult to put it in one Radiobuttong Group. I am not sure its possible or not. I would suggest you do keep both the "Approved" & "Rejected" radio button in single column as shown below so that the memont "Rejected" is selected, "Approved" will be unchecked.
    WHEN 'Your Column'.
            DATA: RAD_GRP TYPE REF TO CL_HTMLB_RADIOBUTTONGROUP,
                     RAD_BTN  TYPE REF TO CL_HTMLB_RADIOBUTTON,
                     COL_BEE TYPE REF TO CL_BSP_BEE_TABLE.
              CREATE OBJECT COL_BEE.
              RAD_GRP = CL_HTMLB_RADIOBUTTONGROUP=>FACTORY(
                      ID = P_CELL_ID COLUMNCOUNT = '2' ).
              COL_BEE->ADD( ELEMENT = RAD_GRP LEVEL = 1 ).
              RAD_BTN ?= CL_HTMLB_RADIOBUTTON=>FACTORY( ID = '1' TEXT = 'Approved' ).
              COL_BEE->ADD( ELEMENT = RAD_BTN LEVEL = 2 ).
              RAD_BTN ?= CL_HTMLB_RADIOBUTTON=>FACTORY( ID = '2' TEXT = 'Rejected' ).
              COL_BEE->ADD( ELEMENT = RAD_BTN LEVEL = 2 ).
              P_REPLACEMENT_BEE ?= COL_BEE.
          ENDCASE.
    Again to get the selected radiobutton, use method REQUEST->GET_FORM_FIELDS
    DATA: GT_TIHTTPNVP TYPE TIHTTPNVP.
    REFRESH GT_TIHTTPNVP.
    CALL METHOD REQUEST->GET_FORM_FIELDS
      CHANGING
        FIELDS = GT_TIHTTPNVP.
    For example, suppose your 3r column has 2 radio buttons & In 1st Row if you've selected the radiobutton 2. THen get_form_fields return the below value.
    TV1_1_3 = 2. Here TV1 is tableview name & 1 - Row 1 & 3 -Column three. value 2 indicates that 2nd radio button is selected.
    DO 10 TIMES. "Here 10, stands for number of visible rows in tableview
    concantenate 'TV1' '_' sy-tabix '_' '3' into v_cell_id. "Here now v_cell_id will have TV1_1_3 for 1st row & etc..
    Read table GT_TIHTTPNVP into wa with key name = v_cell_id.
    if sy-subrc = 0.
    v_selected_rad_btn = wa-value. " THis will give you the selected radio button.
    endif.
    enddo.
    Hope this will solve your problem.
    Raja T
    Message was edited by:
            Raja Thangamani

  • Adding radio button to each row of an interactive report: possible or not?

    First of all let me explain what the point of this application is.
    I'm making an application that allows a user to select something out of a drop-down select list. This list is a list of categories for food. Let's say the user selects "Fruit".
    Then the page refreshes and shows an interactive report with a list of food that belongs to the category of fruit.
    Here's where I want to change things:
    I want the user to see the interactive report, but in this interactive report I want to add a radio button for each row.
    Then, when a certain type of food is selected (let's say "Strawberry") via the radio button, a text field should appear underneath the interactive report. In this textfield, the user can then add the weight of the food item, and then it will calculate how many carbs there are in the strawberry.
    All I really want to know is:*
    How do I add a radio button to each row of the interactive report, and how do I link this radio button to the value of that particular row?*
    Additional information:
    The item "P17_FOOD_CATEGORY" contains the following LOV:
    select FOODCATEGORYNAME as display_value, FOODCATEGORYID as return_value
    from FOODCATEGORY
    order by 1
    The "Food" region contains the following source:
    select a.FOODID, a.NAME, b.FOODCATEGORYNAME, c.STANDARDAMOUNT, c.NAME Unit
    from FOOD a inner join FOODCATEGORY b
    on a.FOODCATEGORYID = b.FOODCATEGORYID join FOODUNIT c
    on a.FOODID = c.FOODID
    where a.FOODCATEGORYID = :P17_SET_CATEGORY
    EDIT:
    PLEASE! Even if you don't know a good answer or if you are unsure about your answer, do post! Even suggestions would be welcome! I really need all the help I could get, even if it's not much.
    Edited by: 917169 on Feb 29, 2012 12:25 AM

    Hi there!
    I tried to change my code to your version, but then I get an error message:
    Error Unable to change Interactive Report query.
    ORA-12899: value too large for column "APEX_040100"."WWV_FLOW_WORKSHEET_COLUMNS"."DB_COLUMN_NAME" (actual: 32, maximum: 30)
    I don't quite know what this means. After doing a quick search on the internet, I know that this message should mean that the length of the value for the columns named "APEX_040100", "WWV_FLOW_WORKSHEET_COLUMNS" and "DB_COLUMN_NAME" is too long. But, I don't have these columns. I searched for them in my object browser, and they can't be found in any table related to my application.
    I'm sure your answer is the solution, but do you perhaps have an idea on how to solve this error? I checked the allowed maximum length for any column value that is related to my application, but they all have "50" set as the maximum value...
    Thank you for your reply. ;)

  • Add a radio button to each row on output (not selection-screen)

    its a normal interacitve report...
    we need to add a radio button to each row on output (not selection-screen) and when user selects the radio button of a particular row and clicks on the user defined menu 'Execute' the report has to fetch the records from a table corresponding to the selected row on the second list.
    all this has to be done in normal interactive list.
    please let me know your suggetions as soon as possible.
    thanks,
    usha.

    Hi ,  try this
    TABLES: spfli.
    TYPE-POOLS:slis.
    PARAMETERS: p_col TYPE i ,
                p_row TYPE i,
                p_color(4) TYPE c .
    DATA: t_fieldcat TYPE slis_t_fieldcat_alv,
          fs_fieldcat LIKE LINE OF t_fieldcat,
          fs_layout TYPE slis_layout_alv ,
          w_color(4) ,
          w_row TYPE i,
          w_fieldname(20),
          w_prog TYPE sy-repid.
    TYPES : BEGIN OF ty_spfli ,
              color(4),
              checkbox ,
              cell TYPE slis_t_specialcol_alv,
              carrid TYPE spfli-carrid,
              connid TYPE spfli-connid,
              cityfrom TYPE spfli-cityfrom,
              cityto TYPE spfli-cityto,
              distance TYPE spfli-distance,
           END OF ty_spfli.
    DATA : wa_spfli TYPE ty_spfli ,
           t_spfli TYPE TABLE OF ty_spfli.
    DATA: fs_cell LIKE LINE OF wa_spfli-cell.
    SELECT carrid connid cityfrom cityto distance
      FROM spfli
      INTO CORRESPONDING FIELDS OF TABLE t_spfli.
    w_color = p_color.
    fs_fieldcat-fieldname = 'CARRID'.
    fs_fieldcat-ref_tabname = 'SPFLI'.
    fs_fieldcat-col_pos = 1.
    fs_fieldcat-key = 'X'.
    APPEND fs_fieldcat TO t_fieldcat.
    CLEAR fs_fieldcat .
    fs_fieldcat-fieldname = 'CONNID'.
    fs_fieldcat-ref_tabname = 'SPFLI'.
    fs_fieldcat-col_pos = 2.
    fs_fieldcat-key = 'X'.
    APPEND fs_fieldcat TO t_fieldcat.
    CLEAR fs_fieldcat .
    fs_fieldcat-fieldname = 'DISTANCE'.
    fs_fieldcat-ref_tabname = 'SPFLI'.
    fs_fieldcat-col_pos = 3.
    fs_fieldcat-key = ' '.
    fs_fieldcat-edit = 'X'.
    APPEND fs_fieldcat TO t_fieldcat.
    CLEAR fs_fieldcat.
    fs_fieldcat-fieldname = 'CITYFROM'.
    fs_fieldcat-ref_tabname = 'SPFLI'.
    fs_fieldcat-col_pos = 4.
    fs_fieldcat-key = ' '.
    APPEND fs_fieldcat TO t_fieldcat.
    LOOP AT t_fieldcat INTO fs_fieldcat.
      IF fs_fieldcat-col_pos EQ p_col.
        fs_fieldcat-emphasize = p_color.
        w_fieldname = fs_fieldcat-fieldname.
        IF p_row IS INITIAL AND p_col GT 0.
          MODIFY t_fieldcat FROM fs_fieldcat TRANSPORTING emphasize.
        ENDIF.
      ENDIF.
    ENDLOOP.
    fs_layout-info_fieldname = 'COLOR'.
    fs_layout-box_fieldname = 'CHECKBOX'.
    fs_layout-coltab_fieldname = 'CELL'.
    fs_layout-f2code = '&ETA'.
    w_prog = sy-repid.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
      EXPORTING
        i_callback_program = w_prog
        is_layout          = fs_layout
        it_fieldcat        = t_fieldcat
      TABLES
        t_outtab           = t_spfli
      EXCEPTIONS
        program_error      = 1
        OTHERS             = 2.
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Regards,
    Aby

  • Creating radio buttons in table coloumn.

    Please share any documents available on how to
    create  and implement radio buttons in table coloumns .
    And please also share how to read the enabled or diaabled radio buttons

    Here is a guide to provide this feature:
    The context:
    - Persons (Node)
    -- Name (Attribute)
    -- SelectedKey (Attribute, String)
    -- Selection (Node, cardinality: 0..1, selection: 1..1, supplyFuntion selectPerson)
    --- KeyToSelect (Attribute, String)
    Layout:
    - Add table with dataSource propertie: Persons
    - Tablerow TextView with propertie text: Persons.Name
    - Tablerow RadioButton with propertie keyToSelect: Persons.Selection.KeyToSelect, selectedKey: Persons.SelectedKey, onSelect: SelectPerson
    Code:
    public void selectPerson(......) {
    ISelectionElement el = node.createSelectionElement();
    node.addElement(el);
    el.setKeyToSelect(parentElement.getName());
    public void onActionSelectPerson(.....) {
    for (int i=0; i < wdContext.nodePersons().size(); i++) {
    if (i != wdContext.nodePersons().getLeadSelection()) {
    wdContext.nodePersons().getElementAt(i).setAttributeValue("SelectedKey", null);
    Method above is for not getting a multiple select (work-around)
    If you have a button in your layout that submits the selection, you can read the selected row with:
    String key = wdContext.nodePersons().currentPersonsElement().getSelectedKey();
    wdComponentAPI.getMessageManager().reportSuccess(key);
    Regards,
    Björn
    Paresh,
    Does this guide solved your problem?
    Message was edited by: B. van Prooijen

  • Radio button in table

    Hi Experts
    My Problem is i need 2 RadioButtons in a Table.so i have inserted 2 RadioButtons (Accept & Reject)in
    cellEditor and i have binded those values to the boolean value which is coming from the BackEnd
    .but my problem is i can select both the radiobuttons and on selecting it is showing an error
    is Not A Valid value.but i need only one radio button to be selected for a row.How can i get this?
    Regards,
    Asif

    I forgot to say that the value node must be non-singleton (singleton=false) such that it exists for every parent node element (table row).
    Say you have the following context structure:
    Rows (node, c=0:n, s=0:n)
    -- Selection (node, c=1:1, s=1:1, singleton=false)
    ---- value (string)
    Add two table columns "AcceptColumn" and "RejectColumn", and add two RadioButtons "AcceptButton", "RejectButton" as cell editors. Bind the "selectedKey" property of both radio buttons to attribute "Rows/Selection/@value". Further assign an action (at least a dummy action) to both buttons.
    Now, to initialize the values for the table rows, write code like
    for (int i = 0, n = wdContext.nodeRows().size(); i < n; i++)
      IRowsElement row = wdContext.nodeRows().getRowsElementAt(i);
      /* this line defines which radio button should be selected in the row at index i: */
      row.currentSelectionElement().setValue("accept"); /* or "reject" */
    To check the value of the radio buttons in row at index i:
    IRowsElement row = wdContext.nodeRows().getRowsElementAt(i);
    String value = row.currentSelectionElement().getValue();
    if ("accept".equals(value))
    else if ("reject".equals(value))
    else
      /* null or illegal value */
    Armin

  • Radio button in table column

    Hi,
    I display a table of data. The user wants to select a row. For this, there is a column called "Select" with a radio button. The user is allowed to select only one column, but they want to do it by clicking on a radio button, not using lead selection. My problem is, that several of the radio buttons are "selected". How do I make only one radio button selectable? I want to be able to click on one radio button, and if I click on another one the first choice should be vacated.
    Or if I were to use lead selection, is there an easy way to tie the radio button with the lead selection. Like, if the user selects a row, can the radio button in this row get turned on automatically?
    I welcome any hints
    Thanks,
    Ira

    Hi Ira,
    I'm not sure I understand why you would want this as lead selection should be sufficient for most selection cases.  Still, one way you could use this is to embed an action hander to the OnLeadSelection event of the table.  Here are my thoughts:
    1. Have an attribute in the context node of type WDY_BOOLEAN or some other boolean to represent your radio button.
    2. Bind the cell editor of your colum to a radio button or check box and set the value to the context attribute.  You will also want to set the enabled setting to FALSE.
    3. Add an action to OnLeadSelect for your table
    4. Have the action handler do your button logic.
    Perhaps if you give an example of the scenario for this, I'd be able to help with the solution.
    Regards,
    Adam

  • Adding Radio buttons to table cell

    Hi,
    Im a beginner in JAVAFX, i would like to add a radio button to table cell.
    Please could anybody help us on this.
    Thanks,
    Dhanraj

    Hi,
    Im a beginner in JAVAFX, i would like to add a radio button to table cell.
    Please could anybody help us on this.
    Thanks,
    Dhanraj

  • Can 3 vertical Radio Buttons span 3 rows in a table? AND how to make form highlight when radio butto

    I am trying to add 3 grouped vertical radio buttons where one is on each line of a 3 row table. When I group the 3 buttons it squeezes them into one row, is there a way I can have them grouped and one in each.
    Also, I would like to know how to make part of the form highlight when one of the 3 buttons is selected

    Hi,
    If I am not wrong, a table cell can hold only one component or none. In order to place the radio group to different positions vertically, you can use subforms instead of table.
    Asiye

  • Default value of radio button on first row in table

    Hi,
    I have created a custom page which includes a table ("SuppliersTable"), the table has a singleSelection table component (radio button) linked to a transient attribute ("SelectFlag") in a VO ("ApSuppliersVO"). The table is populated from a Query region.
    I would like to 'select' the radio button on the first row of the table by default when a query is executed (when a user clicks "Go"), I have tried the following but its not setting the value:
    In CO:
            if (pageContext.getParameter(go) != null) {
                System.out.println("The GO button was pressed");
                am.invokeMethod("handleFirstRows");
            }In AMImpl:
        public void handleFirstRows() {
            System.out.println("1");
            OAViewObject suppliersVO =
                (OAViewObject)findViewObject("ApSuppliersVO");
            if (suppliersVO != null) {
                System.out.println("2");
                int rowcnt = suppliersVO.getRowCount();
                System.out.println("RowCount:" + rowcnt);
                if (suppliersVO.getFetchedRowCount() != 0) {
                    System.out.println("3");
                    //OARow supplierRow = (OARow)suppliersVO.first();
                    Row supplierRow1 = suppliersVO.first();
                    supplierRow1.setAttribute("SelectFlag", "Y");
        }Based on the debug messages I can see that it is calling the procedure, but either not setting the value, or not setting it in a way that renders it on the page and forces the event that goes with it.
    Am I missing something/doing it completely wrong? How can I best achieve this?
    JDEV 10.1.3.3.0
    EBS 12.1.3
    Kind Regards
    Carl

    Hey hi Carl,
    Its pretty much correct , well , can you try the below code .
    OAViewObject localOAViewObject1 = (OAViewObject)am.findViewObject("ProjectDatesVO");
    if(localOAViewObject1!=null) {
    Row DateVoROw = localOAViewObject1.first();
    RowSetIterator iterator = localOAViewObject1.createRowSetIterator("iterator");
    iterator.setRangeStart(0);
    iterator.setRangeSize(localOAViewObject1.getRowCount());
    for(int i=0; i<iterator.getRowCount(); i++)
    DateVoROw=iterator.getRowAtRangeIndex(1); // represents first row
    if(DateVoROw!=null)
    // set the value here .
    Kindly Let me know the update .
    --Keerthi                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to put a radio button ina table

    Hi Frndz..
    I want to show a radio button in a table which table contains multiple rows, so with this radio button user can select only one row out of multi rows.
    My table like this am getting the data from RFC...
                       PONum                  BarCode                    OptionButton
                          100032                   rnsnsv-e3r                   radiobutton
                          100043                   sae489-q3                   radiobutton           
                          100034                   fs88a7-df4                   radiobutton   
    So with the option of radio button user can select only one row..
    while using Insert Table cell editor am adding a radio button but am not able go ahead...suggest me if u have any ideas.
    Thanks in Advance
    Regards
    Rajesh

    Hi Rajesh,
    Try this:
    Step1: Right click on RootUIElementContainer and manually insert the Table
    Step2: Now right click on Table and Insert the TableCoulmn Group
    Step3: In the TableColumnGroup Insert TableColumn
    Step4: Now Insert TableCellEditor  Radio Button Type.
    Step5: Bind the value attributes to the Radio Button property called selectedKey and KeyToSelect and deploy the application
    Thanks
    Krishna

  • Radio button in table maintainenance

    HI Experts,
    In table maintenance view of a table i want to see one field as radio button and want to have checked for one of the entries out of the set of entries.
    My table contain four field.
    Key1 key2 nonkey1 nonkey2
    I want to have nonkey2 as X for only one records for all same key1.
    example data set
    key1  key2 nonkey1 nonkey2
    E1    1    eame   X
    E1    2    eame2
    Here user shd not be able to put second row nonkey2 as X.  This i want to achieve through radio button for nonkey2 in table maintenance.
    Please advise.
    Regards
    Shiv

    > example data set
    >
    > key1  key2 nonkey1 nonkey2
    >
    > E1    1    eame   X
    > E1    2    eame2
    >
    > Here user shd not be able to put second row nonkey2 as X.  This i want to achieve through radio button for nonkey2 in table maintenance.
    Hi Shivaram,
    I could'nt get you....
    If key1 and key2 are different in both cases then why can't the monkey2 be 'X'.
    and the functionality you are talking about can also be easily achieved by using list box which has a value 'Blank' and 'X'.
    Hope it helps you,
    Regards,
    Abhijit G. Borkar

  • Grouping Of radio Buttons in table Control

    Hi All,
              I have one problem in my table control.I am using some radio buttons in the table control.I want that in one row only one button is selected.I have grouped them.But iam not getting mutual exclusivity row wise.Infact I am getting it column wise i.e i am not able to select more than one button in one column but i can select multiple buttons in one row.
    Please suggest.
    Thanks In Advance,
    Saket

    Hi ,
           The above mentioned is the way of creating a radio button in a table control . Can u elaborate on the issue i.e input field disabled.

  • Radio button in table toolbar

    Hi,
    I need to insert a radio button in a table toolbar. Is this possible in WD ABAP.
    Regards
    Azad

    Not available in NW04s SP8.
    In the view element heirarchy, right click on the Toolbar inside the table.
    Then choose insert element.
    The popup has only those elements supported.
    Toolbar_toggle_button is the closest option.
    but no radio button.
    Cheers
    Phil.

Maybe you are looking for