cancel
Showing results for 
Search instead for 
Did you mean: 

Identify what it was selected with Checkbox

Former Member
0 Kudos

In my screen, I am displaying an HTML page with 3 check boxes and I have a button called "Process"

each of these three checkboxes represent a different material number

how can I take the values of these check boxes when user makes the selection

and click the button?

what i have so far is I have a javascript funtion that once the selection is made (checkboxes)

and user click the button I can find out what checkbox was selected but this in javascript so how can I related these with ABAP, my abap internal table?

thanks

neobat

Accepted Solutions (1)

Accepted Solutions (1)

lisa_miller3
Participant
0 Kudos

You can pull the value out of the form fields:

METHOD do_handle_event.

...

    checkbox1 = request->get_form_field( 'checkbox1' ).

.html:

<input type="checkbox" id="checkbox1">

Former Member
0 Kudos

Thanks Lisa.

This worked

Answers (1)

Answers (1)

0 Kudos

Did you use <htmlb:checkbox> element?

If not , I can suggest you to use that element where you need to bind a model class variable against to a checkbox. So your variables will be filled with 'X' if the respected checkbox is checked.

Here is the small exmp:

You must created three vairables in your model class:

say mv_mat_01 , mv_mat_02 and mv_mat_03.

In in your view:

  <htmlb:checkbox id="CHK01"

                            checked = "//model/mv_mat_01"/>

<htmlb:checkbox id="CHK02"

                           checked = "//model/mv_mat_02"/>

<htmlb:checkbox id="CHK03"

                           checked = "//model/mv_mat_03"/>

   here model is Model class objec

*********************************************************************

If you don't want to use htmlb:checkbox element and still you prefer to go ahead with what you have done, then you need to add some more lines of code.

In this scenario also, you need to define three variables in model class as mentioned above.

Now  add three hidden inputfields and which will be bound to respective three model class variables.

<htmlb:inputField  id = "IP_01"

                            value = "//model/mv_mat_01"/>

<htmlb:inputField  id = "IP_02"

                            value = "//model/mv_mat_02"/>

<htmlb:inputField  id = "IP_03"

                            value = "//model/mv_mat_03"/>

Now in your javascript function, try to set value to the hidden fields  by script.

<script>

    function xyz(){

   if(check01.checked == true){

      document.getElementById('IP_01').value = 'X';

  }else{

    document.getElementById('IP_01').value = ' ';

  }

if(check02.checked == true){

     document.getElementById('IP_02').value = 'X';

  }else{

   document.getElementById('IP_02').value = ' ';

  }

if(check03.checked == true){

     document.getElementById('IP_03').value = 'X';

  }else{

   document.getElementById('IP_03').value = ' ';

  }

  }

</script>

I wrote some pseudo code only. You need to write according to your variables or checkbox names/ids.

All the best..

Former Member
0 Kudos

Hello Rama,

I am using straight HTML and JavaScript. I don't use and know these commands such as you described as HTMLB.

in fact, it looks easier what you have

Thanks,

neo