cancel
Showing results for 
Search instead for 
Did you mean: 

radiobutton ,help

former_member233090
Active Contributor
0 Kudos

Hi guru's

I have a small requirement, iam populating data from ztable into a grid(dynamically) and i have added some radiobuttons in the layout with a radiobutton group .

so my requirment is when i click on the radio button i want to track the entire column which i have selected i,e

example

questionno questiondescription good poor

01 quest1 radiobutton1 radiobutton2

btn_submit

01 question 1...... this is coming from ztable1

i have selected radio button1 and click on submit i want to capture this entire coloumn pls help

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member184111
Active Contributor
0 Kudos

Hi,

Are you using HTMLB:tableView or simple HTML code?

former_member233090
Active Contributor
0 Kudos

Iam using HTMLB

former_member233090
Active Contributor
0 Kudos

Its not a table view.. i have just dynmically populated the data... not in the tableview

former_member184111
Active Contributor
0 Kudos

PLz paste the layout code for that part...i am unable to understand how are you displaying tabular format data without tableview?

former_member233090
Active Contributor
0 Kudos

<htmlb:tray id     = "try_questionaire"
                  design = "FORM"
                  width  = "100%"
                  title  = "Project Information" >
        <htmlb:trayBody>
          <htmlb:gridLayout id          = "grd_questionaire"
                            width       = "100%"
                            columnSize  = "7"
<%--                            "<%= l_colsize %>"--%>
                            rowSize     = "32"
                            style       = "ALTERNATING"
                            cellPadding = "3"
                            cellSpacing = "3"
                            height      = "20%" >
            <%
  l_gridrow = 1.
  l_gridcol = 1.
            %>
            <htmlb:gridLayoutCell rowIndex    = "<%= l_gridrow %>"
                                  columnIndex = "<%= l_gridcol %>"
                                  wrapping    = "true"
                                  style       = "BORDER" >
              <htmlb:label for  = "if_questionno"
                           text = "Question NO" />
            </htmlb:gridLayoutCell>
            <%
  l_gridcol = l_gridcol + 1.
            %>
            <htmlb:gridLayoutCell rowIndex    = "<%= l_gridrow %>"
                                  columnIndex = "<%= l_gridcol %>"
                                  style       = "BORDER" >
              <htmlb:label for  = "if_quesdescr"
                           text = "Question Description" />
            </htmlb:gridLayoutCell>
            <%
  l_gridcol = l_gridcol + 1.
            %>
            <htmlb:gridLayoutCell rowIndex    = "<%= l_gridrow %>"
                                  columnIndex = "<%= l_gridcol %>"
                                  width = "7"
                                  style       = "BORDER" >
              <htmlb:label for  = "dd_poor"
                           text = "Poor" />
            </htmlb:gridLayoutCell>
            <%
  l_gridcol = l_gridcol + 1.
            %>
            <htmlb:gridLayoutCell rowIndex    = "<%= l_gridrow %>"
                                  columnIndex = "<%= l_gridcol %>"
                                  width = "7"
                                  style       = "BORDER" >
              <htmlb:label for  = "dd_fair"
                           text = "Good" />
            </htmlb:gridLayoutCell>
            <%
  l_gridrow = 1.
  l_gridcol = 2.
  loop at LT_QUESTION into WA_QUESTION.
    w_sytabix = sy-tabix.
    CONCATENATE 'grpid'
                w_sytabix
            INTO w_groupid.

  l_gridcol = 1.
  l_gridrow = l_gridrow + 1.
  clear l_if_id.
  CONDENSE: l_gridrow, l_gridcol.
  CONCATENATE l_gridrow '_' l_gridcol into l_if_id.
  CONDENSE l_if_id.
            %>
            <htmlb:gridLayoutCell rowIndex            = "<%= l_gridrow %>"
                                  columnIndex         = "<%= l_gridcol %>"
                                  width               = "10"
                                  horizontalAlignment = "CENTER"
                                  style               = "NEGATIVE" >
              <font face="Times New Roman" size="4" color="black">
              <htmlb:textView id        = "<%= l_if_id %>"
                              text      = "<%= WA_QUESTION-QUESTIONNO %>"
                              textColor = "dark blue"
                              layout    = "BLOCK"
                              wrapping  = "X" />
            </htmlb:gridLayoutCell>
            <%
  l_gridcol = l_gridcol + 1.
  CONDENSE: l_gridrow, l_gridcol.
  CONCATENATE l_gridrow '_' l_gridcol into l_if_id.
            %>
            <htmlb:gridLayoutCell rowIndex            = "<%= l_gridrow %>"
                                  columnIndex         = "<%= l_gridcol %>"
                                  width               = "500"
                                  horizontalAlignment = "left"
                                  style               = "NEGATIVE" >
              <font face="Times New Roman" size="4" color="black">
              <htmlb:textView id        = "<%= l_if_id %>"
                              text      = "<%= WA_QUESTION-QUESTIONDESCRIP %>"
                              textColor = "dark blue"
                              layout    = "BLOCK"
                              wrapping  = "X" />
            </htmlb:gridLayoutCell>
            <%

  l_gridcol = l_gridcol + 1.
  CONDENSE: l_gridrow, l_gridcol.
  CONCATENATE l_gridrow '_' l_gridcol into l_if_id.
        %>
            <htmlb:gridLayoutCell rowIndex            = "<%= l_gridrow %>"
                                  columnIndex         = "<%= l_gridcol %>"
                 >

                 <htmlb:radioButtonGroup id = "<%=w_groupid%>" >
              <htmlb:radioButton id="<%= l_if_id %>"

                              disabled  = "<%=w_disable%>" />
      </htmlb:radioButtonGroup>
            </htmlb:gridLayoutCell>
             <%
  l_gridcol = l_gridcol + 1.
  CONDENSE: l_gridrow, l_gridcol.
  CONCATENATE l_gridrow '_' l_gridcol into l_if_id.
        %>
            <htmlb:gridLayoutCell rowIndex            = "<%= l_gridrow %>"
                                  columnIndex         = "<%= l_gridcol %>"
                 >
                 <htmlb:radioButtonGroup id = "<%=w_groupid%>" >
              <htmlb:radioButton id="<%= l_if_id %>"
                              disabled  = "<%=w_disable%>" />
                </htmlb:radioButtonGroup>
            </htmlb:gridLayoutCell>
             <%
 

  endloop.

Edited by: Bhavana Amar on Feb 3, 2010 1:18 PM

former_member233090
Active Contributor
0 Kudos

iam unable to send the code....

former_member184111
Active Contributor
0 Kudos

Bhavana,

Try to paste the code by misspeling the HTMLB tags and java script code..like for table use tab_le etc..

It will be easier and more organised to use tableView for displaying the data in tabular format. Eventhandling will also be easy.

former_member233090
Active Contributor
0 Kudos

l_gridrow = 1.

l_gridcol = 2.

loop at LT_QUESTION into WA_QUESTION.

w_sytabix = sy-tabix.

CONCATENATE 'grpid'

w_sytabix

INTO w_groupid.

l_gridcol = 1.

l_gridrow = l_gridrow + 1.

clear l_if_id.

CONDENSE: l_gridrow, l_gridcol.

CONCATENATE l_gridrow '_' l_gridcol into l_if_id.

CONDENSE l_if_id.

%>

<htmlb:gridLayoutCell rowIndex = "<%= l_gridrow %>"

columnIndex = "<%= l_gridcol %>"

width = "10"

horizontalAlignment = "CENTER"

style = "NEGATIVE" >

<font face="Times New Roman" size="4" color="black">

<htmlb:textView id = "<%= l_if_id %>"

text = "<%= WA_QUESTION-QUESTIONNO %>"

textColor = "dark blue"

layout = "BLOCK"

wrapping = "X" />

</htmlb:gridLayoutCell>

<%

l_gridcol = l_gridcol + 1.

CONDENSE: l_gridrow, l_gridcol.

CONCATENATE l_gridrow '_' l_gridcol into l_if_id.

%>

<htmlb:gridLayoutCell rowIndex = "<%= l_gridrow %>"

columnIndex = "<%= l_gridcol %>"

width = "500"

horizontalAlignment = "left"

style = "NEGATIVE" >

<font face="Times New Roman" size="4" color="black">

<htmlb:textView id = "<%= l_if_id %>"

text = "<%= WA_QUESTION-QUESTIONDESCRIP %>"

textColor = "dark blue"

layout = "BLOCK"

wrapping = "X" />

</htmlb:gridLayoutCell>

<%

l_gridcol = l_gridcol + 1.

CONDENSE: l_gridrow, l_gridcol.

CONCATENATE l_gridrow '_' l_gridcol into l_if_id.

%>

<htmlb:gridLayoutCell rowIndex = "<%= l_gridrow %>"

columnIndex = "<%= l_gridcol %>"

>

<htmlb:radioButtonGroup id = "<%=w_groupid%>" >

<htmlb:radioButton id="<%= l_if_id %>"

disabled = "<%=w_disable%>" />

</htmlb:radioButtonGroup>

</htmlb:gridLayoutCell>

<%

l_gridcol = l_gridcol + 1.

CONDENSE: l_gridrow, l_gridcol.

CONCATENATE l_gridrow '_' l_gridcol into l_if_id.

%>

<htmlb:gridLayoutCell rowIndex = "<%= l_gridrow %>"

columnIndex = "<%= l_gridcol %>"

>

<htmlb:radioButtonGroup id = "<%=w_groupid%>" >

<htmlb:radioButton id="<%= l_if_id %>"

disabled = "<%=w_disable%>" />

</htmlb:radioButtonGroup>

</htmlb:gridLayoutCell>

<%

endloop.

matt
Active Contributor
0 Kudos

Let me try: (( replaces &lt;)) replaces &gt;<br> <pre>((htmlb:tray id = "try_questionaire"

design = "FORM"

width = "100%"

title = "Project Information" ))

((htmlb:trayBody))

((htmlb:gridLayout id = "grd_questionaire"

width = "100%"

columnSize = "7"

((%-- "((%= l_colsize %))"--%))

rowSize = "32"

style = "ALTERNATING"

cellPadding = "3"

cellSpacing = "3"

height = "20%" ))

((%

l_gridrow = 1.

l_gridcol = 1.

%))

((htmlb:gridLayoutCell rowIndex = "((%= l_gridrow %))"

columnIndex = "((%= l_gridcol %))"

wrapping = "true"

style = "BORDER" ))

((htmlb:label for = "if_questionno"

text = "Question NO" /))

((/htmlb:gridLayoutCell))

((%

l_gridcol = l_gridcol + 1.

%))

((htmlb:gridLayoutCell rowIndex = "((%= l_gridrow %))"

columnIndex = "((%= l_gridcol %))"

style = "BORDER" ))

((htmlb:label for = "if_quesdescr"

text = "Question Description" /))

((/htmlb:gridLayoutCell))

((%

l_gridcol = l_gridcol + 1.

%))

((htmlb:gridLayoutCell rowIndex = "((%= l_gridrow %))"

columnIndex = "((%= l_gridcol %))"

width = "7"

style = "BORDER" ))

((htmlb:label for = "dd_poor"

text = "Poor" /))

((/htmlb:gridLayoutCell))

((%

l_gridcol = l_gridcol + 1.

%))

((htmlb:gridLayoutCell rowIndex = "((%= l_gridrow %))"

columnIndex = "((%= l_gridcol %))"

width = "7"

style = "BORDER" ))

((htmlb:label for = "dd_fair"

text = "Good" /))

((/htmlb:gridLayoutCell))

((%

l_gridrow = 1.

l_gridcol = 2.

loop at LT_QUESTION into WA_QUESTION.

w_sytabix = sy-tabix.

CONCATENATE 'grpid'

w_sytabix

INTO w_groupid.

l_gridcol = 1.

l_gridrow = l_gridrow + 1.

clear l_if_id.

CONDENSE: l_gridrow, l_gridcol.

CONCATENATE l_gridrow '_' l_gridcol into l_if_id.

CONDENSE l_if_id.

%))

((htmlb:gridLayoutCell rowIndex = "((%= l_gridrow %))"

columnIndex = "((%= l_gridcol %))"

width = "10"

horizontalAlignment = "CENTER"

style = "NEGATIVE" ))

((font face="Times New Roman" size="4" color="black"))

((htmlb:textView id = "((%= l_if_id %))"

text = "((%= WA_QUESTION-QUESTIONNO %))"

textColor = "dark blue"

layout = "BLOCK"

wrapping = "X" /))

((/htmlb:gridLayoutCell))

((%

l_gridcol = l_gridcol + 1.

CONDENSE: l_gridrow, l_gridcol.

CONCATENATE l_gridrow '_' l_gridcol into l_if_id.

%))

((htmlb:gridLayoutCell rowIndex = "((%= l_gridrow %))"

columnIndex = "((%= l_gridcol %))"

width = "500"

horizontalAlignment = "left"

style = "NEGATIVE" ))

((font face="Times New Roman" size="4" color="black"))

((htmlb:textView id = "((%= l_if_id %))"

text = "((%= WA_QUESTION-QUESTIONDESCRIP %))"

textColor = "dark blue"

layout = "BLOCK"

wrapping = "X" /))

((/htmlb:gridLayoutCell))

((%

l_gridcol = l_gridcol + 1.

CONDENSE: l_gridrow, l_gridcol.

CONCATENATE l_gridrow '_' l_gridcol into l_if_id.

%))

((htmlb:gridLayoutCell rowIndex = "((%= l_gridrow %))"

columnIndex = "((%= l_gridcol %))"

))

((htmlb:radioButtonGroup id = "((%=w_groupid%))" ))

((htmlb:radioButton id="((%= l_if_id %))"

disabled = "((%=w_disable%))" /))

((/htmlb:radioButtonGroup))

((/htmlb:gridLayoutCell))

((%

l_gridcol = l_gridcol + 1.

CONDENSE: l_gridrow, l_gridcol.

CONCATENATE l_gridrow '_' l_gridcol into l_if_id.

%))

((htmlb:gridLayoutCell rowIndex = "((%= l_gridrow %))"

columnIndex = "((%= l_gridcol %))"

))

((htmlb:radioButtonGroup id = "((%=w_groupid%))" ))

((htmlb:radioButton id="((%= l_if_id %))"

disabled = "((%=w_disable%))" /))

((/htmlb:radioButtonGroup))

((/htmlb:gridLayoutCell))

((%

endloop.</pre>

<br><br>You also had too many characters in your post - maximum is 2500... there are ways around it, obviously.

former_member184111
Active Contributor
0 Kudos

Hi Bhanava,

First thing is why are the two radio buttons in two different radio button groups? I guess the both radio buttons should be in same group.

Anyways you can add the code

htmlb:radioButton id="((%= l_if_id %))"
                disabled  = "((%=w_disable%))" 
                on_click = 'poor'  <--remove underscore

htmlb:radioButton id="((%= l_if_id %))"
                disabled  = "((%=w_disable%))" 
                on_click = 'good'

<--remove underscore

in the respective radio button codes. This will trigger a server event that you can handle in onInputprocessing.

Data: rb_event type ref to cl_htmlb_event_radiobutton,
          event  type ref to if_htmlb_data .

event  = cl_htmlb_manager->get_event( request ).

IF event is not initial and event->event_name = htmlb_events=>radiobutton.
rb_event ?= event .
case event->event_server_name.
when 'poor' .

when 'good'.

endcase.
ENDIF.

You need to debugg and check which variable in objetc event contains the ID of radio button that triggered the event, most probably it is event->event_id check it. Now based on the id of radio button that triggered the server event you can get the row number for which the rb is selected.

Now you can read the other form data for that row using call method request->get_form_fields .

Regards,

Anubhav

former_member233090
Active Contributor
0 Kudos

Hi thanks for ur reply...

but i don't want the action to be done on the radio button,

as i told u i have a button called submit at the end of the page, so when i click on the submit, it should capture the radio button which has been clicked pls help me

former_member184111
Active Contributor
0 Kudos

Hi Bhavana,

In that case you first need to have two different IDs for the radio buttons. The naming convention for radio buttons should be rb_rownum_colnum for ex. if there are 3 rows, RB poor is column 4 and RB good is column 5 then for

first row the IDs of rbs will be rb_1_4 and rb_1_5

second row the IDs of rbs will be rb_2_4 and rb_2_5

third row the IDs of rbs will be rb_3_4 and rb_3_5

Now when the submit button is pressed use the below code..

Data: lt_fields type tihttpnvp .
data: ls_value type ihttpnvp.

call method request->get_form_fields
     changing
                       fields = lt_fields .

The table lt_fields will contain name value pair like if you selected poor in first row and good in second row then you will see that lt_fields contains

Name                       Value
rb_1_4                     X
rb_2_5                     X

for other radio buttons value will be initial.

Now you have all the rows for which RBs are selected and what RB was selected. You can read rest of the form data for that row.

Regards,

Anubhav

former_member233090
Active Contributor
0 Kudos

Thanks for ur help ....

When i debug i am able to find the values since my code is dynamically generating the grid row and coloumn i can see the values as

1 2 3 4

1 quesno question desc poor good

2 1 question1 rb2(selected) it is in gridrow and coloumn wise.. hope u understand

so in debugging i can see radiobuttongroup grid as 2_4 with help of ur code, but tell me how shd i get it in the handle date. help me Abinav

former_member184111
Active Contributor
0 Kudos

Hi Bhavana,

but tell me how shd i get it in the handle date

sorry unable to understand which date are you talking about.

Paste the code of internal table lt_values as you see in debugging in name value pair and clarify your question more...

former_member233090
Active Contributor
0 Kudos

First thing as u know....... iam populating data from internal table in to the page as

questionno question description these two fields are coming from internal table and now into the page i have added radio buttons as good poor excellent, to be more clear every question will have the ratings as good poor excellent.

so as i told you before all these are getting generated dynamically , even the buttong group id also. as i hv sent the code

so everything is done and now when i click on the radio buttons for the questions and click on submit button another ztable iam using where i have fields like

question no

good

poor

excellent

so based on the question no these fields has to be caputed and filled...

got it?

former_member184111
Active Contributor
0 Kudos

Ok so in the second internal table you have only two columns

Question No. and Rating (poor/good/excelent)..right?

So the most important part is the IDs of radio buttons has to be in a way so that you can identify for which row no. the RB is selected and what RB is selected.

Now you have this data (row no. and rating) in lt_values table.

Suppose there are two rows 1st poor and 2nd good

Name         Value
rb_1_4         X
rb_2_5         X

rest RBs are initial in lt_values.

data: lv_cellid type string,
         lv_rowno(2),
         lv_colno(2).
        lv_ttl_rows(2). 

**if your first internal tabel has 3 records.
describe table it_main lines lv_ttl_rows <---now lv_ttl_rows contains the total no. of qauestions or u can say total no. of rows in main table.

do lv_ttl_rows times.
concatenate lv_cell_id 'rb_' sy-tabix '_4' into lv_cell_id <--for first run this lv_cell_id will comtain rb_1_4 
read table lt_values into ls_values with key name = lv_cell_id.
if ls_values-value = 'X'   <--if the radio button is selected
     wa_ztable-quesno = sy-tabix.
     wa_ztable-rating = 'poor'.   <---since column 4 has radio button for poor rating
append wa_ztable to ztable.

concatenate lv_cell_id 'rb_' sy-tabix '_5' into lv_cell_id <--for first run this lv_cell_id will comtain rb_1_5 
read table lt_values into ls_values with key name = lv_cell_id.
if ls_values-value = 'X'   <--if the radio button is selected
     wa_ztable-quesno = sy-tabix.
     wa_ztable-rating = 'good'.   <---since column 5 has radio button for good rating
append wa_ztable to ztable.

endif.

enddo.

Hope it will solve the issue..

former_member233090
Active Contributor
0 Kudos

Hi Anubhav Jain

wow.. ur code helped me alot.. iam 75% done

my problem now is..

i said i have a table with

question no not ratings as coloumn but its like

questionno

good

poor

excellent

these are the coloumns i have so when i read the table in debugging the form fields

when i read the form fields with table key name =""

name value

grpid 2_3

i am able to read the table form feild with key value

now if sy-subrc eq 0.

then how shd i make it as 'X'

it may be poor

or good na

former_member233090
Active Contributor
0 Kudos

DESCRIBE TABLE ME->M_EVECAL->LT_QUESTION LINES W_LINE.

L_GRIDCOL = 1.

L_GRIDROW = 2.

CLEAR W_LINE.

DESCRIBE TABLE FORM_FIELDS LINES W_LINE.

DO W_LINE TIMES. "LOOP AT FORM_FIELDS ASSIGNING <FIELD>.

CLEAR L_IF_ID.

CONDENSE: L_GRIDROW, L_GRIDCOL.

CONCATENATE L_GRIDROW '_' L_GRIDCOL INTO L_IF_ID.

CONDENSE L_IF_ID.

READ TABLE FORM_FIELDS

WITH TABLE KEY NAME = L_IF_ID

ASSIGNING <FIELD>.

WA_FEEDFINAL-QUESTIONNO = <FIELD>-VALUE.

L_GRIDCOL = L_GRIDCOL + 1.

CLEAR L_IF_ID.

CONDENSE: L_GRIDROW, L_GRIDCOL.

CONCATENATE L_GRIDROW '_' L_GRIDCOL INTO L_IF_ID.

CONDENSE L_IF_ID.

READ TABLE FORM_FIELDS

WITH KEY VALUE = L_IF_ID

ASSIGNING <FIELD>.

IF SY-SUBRC EQ 0.

  • WA_FEEDFINAL-POOR = 'X'.-------------> this is my confusion... some times poor will come ,or sometimes good will come so how..... becoz of my dynamically populating iam unable too write the above code

ENDIF.

ENDDO.

former_member184111
Active Contributor
0 Kudos
DESCRIBE TABLE ME->M_EVECAL->LT_QUESTION LINES W_LINE.
L_GRIDCOL = 1.
L_GRIDROW = 2.
CLEAR W_LINE.
DESCRIBE TABLE FORM_FIELDS LINES W_LINE. <--remove this line, we wil execute DO ENDO loop only for the total no. of questions.

DO W_LINE TIMES. "LOOP AT FORM_FIELDS ASSIGNING <FIELD>.
CLEAR L_IF_ID.
CONDENSE: L_GRIDROW, L_GRIDCOL.
CONCATENATE L_GRIDROW '_' L_GRIDCOL INTO L_IF_ID.
CONDENSE L_IF_ID.

READ TABLE FORM_FIELDS
WITH TABLE KEY NAME = L_IF_ID
ASSIGNING <FIELD>.
WA_FEEDFINAL-QUESTIONNO = <FIELD>-VALUE.
L_GRIDCOL = L_GRIDCOL + 1.
CLEAR L_IF_ID.
CONDENSE: L_GRIDROW, L_GRIDCOL.
CONCATENATE L_GRIDROW '_' L_GRIDCOL INTO L_IF_ID.
CONDENSE L_IF_ID.
READ TABLE FORM_FIELDS
WITH KEY VALUE = L_IF_ID<--here l_if_id contains ID of radio button group or radio button? It has to the id of radio button. Only if we have the id of radio button here and this id contains row no. and col no. we can get the selected value for particular row
ASSIGNING <FIELD>.
IF SY-SUBRC EQ 0.
* WA_FEEDFINAL-POOR = 'X'.
ENDIF.
ENDDO.
former_member233090
Active Contributor
0 Kudos

It contain radio button id i,e

like if i select

questno questiondesri good poor

1 hi? X

so in l_if_id we get 2_3 ok

former_member184111
Active Contributor
0 Kudos
2_3

what is the breakup of this id i mean is 2 the row num and 3 the column num?

former_member233090
Active Contributor
0 Kudos

yes...

former_member184111
Active Contributor
0 Kudos
Col1          Col2                 Col3          Col4
questno    questiondesri   good         poor
1                 hi                      X

the structure of your Z table is it contains 4 columns

question no.

poor

good

excelent

for value 2_3 means that 2nd row 3rd (good) column is selected

do lv_ttl_rows times.
concatenate lv_cell_id sy-tabix '_3' into lv_cell_id <--for second run this lv_cell_id will contain 2_3 
read table lt_values into ls_values with key name = lv_cell_id.
if ls_values-value = 'X'   <--if the radio button is selected
     wa_ztable-quesno = sy-tabix.
     wa_ztable-poor  = ''.
     wa_ztable-good  = 'X'.
     wa_ztable-excelent  = ''.
append wa_ztable to ztable.
enddo.

former_member184111
Active Contributor
0 Kudos

Bhavana,

Are you still facing any issues or is it solved?

former_member184111
Active Contributor
0 Kudos

Bhavana,

Please share the solution with forum, is it very different from what i suggested?

former_member233090
Active Contributor
0 Kudos

Hi Anubhav.....

with help of ur suggestions , my problem got solved........