cancel
Showing results for 
Search instead for 
Did you mean: 

Making checkboxes mandatory on SUBMIT.

Former Member
0 Kudos

Hi,

How do I make a checkbox group mandatory , based on the selection of some checkboxes, in a previous section.

Eg:

If the user selects a checkbox, then the selection of some checkboxes in the following checkbox group in the subsequent section has to be mandatory.

How do I do that.

Regards,

Gautam

Accepted Solutions (0)

Answers (1)

Answers (1)

raja_thangamani
Active Contributor
0 Kudos

First Reward/Reply/Close the below threads..

Regarding your question...

You need to read the checkbox say C1. If C1 is checked then Checkbox C2 from subsequent section...


* OnInputprocessing:
        CALL METHOD REQUEST->GET_FORM_FIELD
          EXPORTING
            NAME  = 'c1'
          RECEIVING
            VALUE = V_CHECKED.
        IF V_CHECKED IS NOT INITIAL.
* Check C2 is checked or not..         
        ENDIF.

Raja T

Former Member
0 Kudos

Thanks for the answer,

But how do I get the value of the checkbox, and what is the value of a checkbox.

One thing when my BSP page refreshes, the 'tick' in the checkbox, vanishes, and the application pops up a message, that a particular category has not been checked.

and how do I make my checkboxes stateful, i.e it doesnt lose their 'tick' even when the page refreshes.

Regards,

Gautam

raja_thangamani
Active Contributor
0 Kudos

variable v_checked will have 'X' or Space..

          <htmlb:checkbox id      = "c1"
                           checked = "<%= v_checked %>"

<b>* Reward each useful answer</b>

Raja T

Former Member
0 Kudos

But ,when my page refreshes( roundtrip), the the tick in the checkbox is gone, after the occurence of an event.

I have been facing this situation earlier for input boxes, but I solved it ,,its not happening for a CHECKBOX.

How do I stop that.

Gautam

raja_thangamani
Active Contributor
0 Kudos

Use the below code, it will solve your problem...

<b>Layout:</b>

 <htmlb:checkbox id      = "c1"
                           checked = "<%= v_checked %>"

<b>OnInputprocessing:</b>

* OnInputprocessing:
        CALL METHOD REQUEST->GET_FORM_FIELD
          EXPORTING
            NAME  = 'c1'
          RECEIVING
            VALUE = V_CHECKED.

<b>Page attribute:</b>

v_checked TYPE STRING

Try this & let me know..Its working fine..

<i>* Reward each useful answer</i>

Raja T

Former Member
0 Kudos

Is it possible to keep the tick without using code.

Does it have something to do with Stateful and stateless settings.

Can u please check and tell me.

Because I have a checkbox in a loop structure , hence it has only one value which changes as per the loop.

If it ould hve been a static structure then I would have surely used your method, but Rite now I am not bale to use it.

Regards,

Gautam

raja_thangamani
Active Contributor
0 Kudos

Yes if your application is stateless then u have to use the code..

Even in your case, you can use the code as follows:

<b>Layout:</b>

<% data: v_checkbox_id type string,
      sy_tabix type string.
 
Loop at itab_map into wa_map.
sy_tabix  = SY-TABIX.
 concatenate v_checkbox_id 'CHK' sy_tabix into v_checkbox_id.%>
 
<td> 
 
<htmlb:checkbox id = "<%= v_checkbox_id %>"
checked = "<%= wa_map-field1 %>" />
 
</td>
 
<% ENDLOOP.
%>

<b>In Oninputprocessing:</b>

DATA: GT_TIHTTPNVP TYPE TIHTTPNVP.
data: v_checkbox_id type string,
         wa_formfields      TYPE ihttpnvp,
      sy_tabix type string.
 
REFRESH GT_TIHTTPNVP.
 
CALL METHOD REQUEST->GET_FORM_FIELDS
  CHANGING
    FIELDS = GT_TIHTTPNVP.
 
Loop at itab_map into wa_map.
sy_tabix  = SY-TABIX.
 concatenate v_checkbox_id 'chk' sy_tabix into v_checkbox_id.
 
      READ TABLE GT_TIHTTPNVP INTO wa_formfields WITH KEY name = v_checkbox_id.
      wa_map-field1 = wa_formfields-value.
   append wa_map to itab_map.
endloop.

This will solve the problem..

<i>* Reward each useful answer</i>

Raja T

Former Member
0 Kudos

But , I have made my application stateful,,I actually copied SAP standard, to a Z-type, and then added my code, and I have made the application stateful.

Regards,

Gautam

raja_thangamani
Active Contributor
0 Kudos

Please try to use the <b>code</b> & check..Let me know..

Raja T