Javascript to check if a checkbox is selected in datatable

Hi,
I have a form with some command buttons and couple of datatables with checkboxes in one of the columns. How do I make sure when a user clicks on any command button to generate an action only if any checkbox is selected else shows an error to atleast select one checkbox. Is it possible do that using javascript rather than on the server side. Any small example will help.
Thanks

Hi Detlev,
I searched for the file controls_ie5.js. But I have only one function for cell click in js file. I didnt get any methods you mentioned in the reply.
The workaround I could see is, get the name of the tableview control using 'myContext.getParamIdForComponent("tableviewcontrolname")'. Then append '-chk'(that is the name generated dynamically for the radio button in the HTML page). With this we can do a javascript validation if a radio button is selected. The only disadvantage is if they change the naming conventions(say instead of -chk if they use _chk) for HTMLB implementation this code will fail.
In another post I saw a reply from Stephan Batzdorf for similar post. He says, "Now to the client side. The only thing you can do on client-side is to retrieve the selected rows and get the values from the key column.
It's not possible to manipulate data. Of course you can render InputFields into table cells and let the user manipulate them, but then you have to retrieve each value for each InputField again on server side (pageContext.getComponentForId(tableCellInputFieldId);)."
  Does he say we cant get the value of inputfield in the client side?
I will definitely award points once the problem is fixed.
Regards,
Priya

Similar Messages

  • Can I cause checking a box to add 1 to a calculated form field?  I have a field that sums the numbers entered in several previous fields and need to be able to add "1" if a checkbox is selected as well.

    Can I cause checking a box to add 1 to a calculated form field?  I have a field that sums the numbers entered in several previous fields and need to be able to add "1" if a checkbox is selected as well.

    I think it has something to do with the way the value of the check box is exported, but I'm not sure.  With nothing being exported to Data5, Data6 displays the sum of Data1-4 rounded down to the nearest whole number and updates automatically as Data1-4 are updated.
    Right now, assuming Data1-4 are 0, where data 5 is the output of the second example and any box is checked,  "1" is displayed in data5 but nothing is added to data 6. Selecting any other check box or deselecting that check box will cause data6 to add 1 even if data5 displays "0".  By way of example:
    Selecting Check box 16 results in Data5 displays 1 and Data6 displays zero.
    Then, if any or all of Checkbox17-20 are selected, Data5 displays 1 and Data6 displays 1.
    Then, if any or all of Checkbox17-20 are deselected, Data5 Displays 1 and Data6 displays1.
    Then, if Checkbox16 is deselected, Data5 displays 0 and Data6 displays 1.

  • Every time I open a pdf file which includes a javascript, a dialogue box pops up. I have a question why 'Do not show this message again' is not working even I checked on the checkbox. It should block the dialogue next time when I open the same pdf file bu

    Every time I open a pdf file which includes a javascript, a dialogue box pops up. I have a question why 'Do not show this message again' is not working even I checked on the checkbox. It should block the dialogue next time when I open the same pdf file but not working. What is the matter and how can I deal with it?

    I am trying it on Adobe Acrobat Reader 9.2.1. Tried to fix Hex code, and also tried 'edit-preference-trust manager'. I focusing on Adobe registries but still couldn't fix the problem.

  • Javascript to check only one of the two checkboxes in JSF

    Hi,
    I have this working in HTML, but when trying to simulate the same in JSF, I get error.
    <input id="checkbox1" type="checkbox" onClick="selecionatudo(true,1)"/>
    <input id="checkbox1" type="checkbox" onClick="selecionatudo(true,2)"/>
    Javascript
    function selecionatudo(check,n) {
    var frm = document.getElementById('form1');
    for (i=0;i<2;i++) {
    if (check) {
    frm.checkbox1.checked=false;
    frm.checkbox1[n-1].checked=true;
    JSF checkboxes
    A<h:selectBooleanCheckbox id="checkbox1" onclick="selecionatudo(true,1)"/></h:selectBooleanCheckbox>
    B<h:selectBooleanCheckbox id="checkbox2" onclick="selecionatudo(true,2)"/></h:selectBooleanCheckbox>
    Since in <h:selectBooleanCheckbox I cannot use the id attribute which can hold duplicate values, I get an error, using the above method.
    Also, <h:selectBooleanCheckbox cannot have a name attribute .(having which, I can use the above Javascript to work)
    Please help me.

    Hi!
    I think that:
    If you have pairs of checkboxes to make actions, you can try to set id in Jsf like this " checkBoxA1" and "checkBoxA2".
    Then in JavaScript, you can get de string "checkBoxA" and build the two id's, adding and "1" and "2".
    Later, you can do that you want.
    But, I think that in JavaScript across Jsf, you can't use "frm.checkbox1", i think that you must use: "document.getElementById("checkbox1").
    I'm a starter in Jsf and very bad with English, but I hope that it help you!
    Regards!

  • Editable Checkbox and select the checked line in ALV output

    HI,
    I am looking for an ALV output using LIST_DISPLAY with an editable check box in each item in the output.It should be editable and also the line which is checked should be selected for further action.
    Can you please help...
    Thanks in Advance
    Regards,
    Gangolu

    Hi
    1) Declare your intertable with a field named <CHECK>.
    For example:
    data: begin of i_sales occurs 0,
                 matnr like vbap-matnr,
                 erdat like vbak-erdat,
                 check type c, "checkbox
    end of i_sales.
    2) In your field catalog, put the first column as check box like below:
    v_fieldcat-col_pos = 1.
    v_fieldcat-fieldname = 'CHECK'.
    v_fieldcat-seltext_m = 'check'.
    v_fieldcat-checkbox = 'X'.
    v_fieldcat-input = 'X'.
    v_fieldcat-edit = 'X'.
    append v_fieldcat to gt_fieldcat.
    3) Call function 'REUSE_ALV_GRID_DISPLAY'
        FUNCTION 'REUSE_ALV_GRID_DISPLAY'
            EXPORTING
                I_CALLBACK_PROGRAM = sy-repid
                I_CALLBACK_PF_STATUS_SET = 'GUI_SET'
               I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
    4) You must have a form called <USER_COMMAND> if you want to select that line and perform some action on it
    Example:
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM R_SELFIELD TYPE SLIS_SELFIELD.
    Case R_UCOMM.
    endcase
    Regards
    Dean Q.

  • In struts how to check if a checkbox must be selected?

    i want to be be able to give an error message the checkboxes arent selected using struts html:error tag how do that..

    Try
    checkbox1.getSelected()
    this is the function that works in JSC 2.

  • Uncheck a Checkbox when Select List Clicked

    version 4.0.2.00.06
    Hello,
    Jari helped me with a javascript function to select all options in a multi-select list when a checkbox is checked by the user.
    A bug was reported that after clicking the checkbox to select all the options in the list, if the user then clicks on a single value in the select list the checkbox is still checked.
    Would someone help me with how to uncheck the checkbox when a single value is selected in the select list after the checkbox is checked to select all of the options in the select list?
    If you need more information please let me know.
    Thanks,
    Joe

    Hi,
    Same sample as in this post
    Re: The requested URL /apex/wwv_flow.accept was not found on this server
    I did add page JavaScript
    function checkSelected(pThis,pChk,pVal){
    var self=$($x(pThis));
    var o=self.find("option");
    var s=self.find("option:selected");
    if(s.length==o.length){
      $s(pChk,pVal);
    }else{
      $s(pChk,"");
    }And to P65_EMP multiu select HTML Form Element Attributes
    onchange="checkSelected(this,'P67_SELECT_ALL','ALL')"Regards,
    Jari

  • User of Checkbox/ Radio Selections.doc

    User of Checkbox/ Radio Selections.doc
    Thank you, this is very informative and helpful. In the doc you mentioned about a cfm file, however I was not able to see the file. Will you be able to explain a bit about it?

    Hi,
    here
    you´ll find an explanation, working example and the related
    javascript code

  • How to un-check everything in a Multi-selection list box in SP2013?

    When a radio button is selected/un-selected, i would like to clear all the checkboxes that were checked in a MSLB.  I created a rule for the condition but in the action, how to create this uncheck action?
    Thank you

    yes, that's what I've done but still not working.  I even downloaded the sp, 
    InfoPath 2013 (KB2837648) 32-Bit Edition
    and it still doesn't work.  In the screen shot attached, ml prefix is for Multi-selection list box.  So, in mlImprovement, if the Communication checkbox isn't checked then set the Multi-selection list box, Communicaiton, to blank so it should
    show no selection.
    In the preview of Infopath 2013, I would check Communication in mlImprovement and then check a couple of checkboxes in mlCommunicaiton.  I then uncheck and check Communicaiton in mlImprovement and those previously checked checkboxes remains.
    I have been very frstrated working the MLSB infopath 2013.  there are other issues that does't work either.  Please advise if I'm missing a step here and there, thank you.

  • Not able to Check Delta Enabled Checkbox in Datasource

    Hi,
    I created a Custom Datasource in ECC system which extracts data through Function module.  I activated the Datasource without checking the Delta checkbox.  Only when i created Infopackage in BI, i realized my mistake.  When i try to go back to ECC system, i could see that the Delta Enabled check box is now disabled, i am not able to check it now. 
    Is there any way i can make this datasource to Delta enabled in ECC system now?
    Regards,
    Murali

    yes Murali you need to maintain the delta in RSO2.
    select radio button -timestamp local and enter your field:AEDAT.
    check the upper limit n lower limit with functional team so that you do not miss any delta records.
    Check the below link for more detail
    [Geeric Delta|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/84bf4d68-0601-0010-13b5-b062adbb3e33]

  • How to check whether a checkbox is checked

    This code:
          if (checkBoxCSharpShown.IsChecked)
            checkBoxCSharpShown.IsChecked = false;
    elicits:
    "Cannot implicitly convert type 'bool?' to 'bool'. An explicit conversion exists (are you missing a cast?)"
    How can I check whether the checkBox is checked?
    Delphi ancient/C# newbie

    So why is this so complicated? Why doesn't a check box have a true/false value? The answer is that a checkbox can (optionally and not by default) be a three-state control.
    When ThreeState is true, the checkbox has three states:
    Checked
    Not Checked
    Indeterminate
    They correspond to these tests:
    bool checked = IsChecked.HasValue && IsChecked.Value == true
    bool unchecked = IsChecked.HasValue && IsChecked.Value == false
    bool indeterminate = IsChecked.HasValue == false
    One of the ways a three-state checkbox is used is in a property dialog. If the user selects multiple items (all having some boolean property called 'Active'--for instance), what should the proprety dialog show for that selection if the value of Active is different among the selected items? Should it show True? That wouldn't work, they are not all True, same for False. So instead the property dialog would show Indeterminate, indicating that the collection of Active values is neither True, nor False.
    Now having said all of that I'll refer you to:
    CheckBox.Checked
    This is true or false. If the ThreeState property is True, Checked returns True for True or Indeterminate.

  • Use spacebar to check/uncheck a checkbox in a datagrid.

    I have a DataGrid that has checkbox in the first column. The user wants to be able to check/uncheck the checkbox when he selects a row, by mouse or up and down keys, and hits the spacebar. Currently the spacebar functions if the last thing that the use has clicked on is the Checkbox. If the user clicks in the cell where the checkbox in located(not the checkbox itself), the spacebar won't do anything.
    <mx:TabNavigator>
         <mx:VBox>
              <ms:datagrid id="lgGrid" dataProvider="{this.lData}">
                   <mx:columns>
                        <mx:Array>
                             <mx:DataGridColumn dataField="vis" id="dfID" sortable="false">
                                  <mx:itemRenderer>
                                       <mx:Component>
                                            <mx:CheckBox click="data.vis = !data.vis"  paddingLeft="4"/>
                                       </mx:Component>
                                  </mx:itemRenderer>
                              </mx:DataGridColumn>
                              <mx:DataGridColumn dataField="name"/>
                        </mx:Array>
                   </mx:columns>
              </ms:datagrid
       </mx:VBox>
    </mx:TabNavigator>

    Your TableModel has to indicate that the column is editable. Your TableModel also has to implement setValueAt() so that when the user changes the value, it updates the data.
    The table will know to use it's own boolean renderer/editor for that column because it knows what to do when a column returns a Boolean.

  • Show the checkbox as selected by selecting the row.

    Hi friends,
    I have a table. It is possible to select multiple rows, after selecting rows, I get the selected
    rows in this table from the context. Now my question is, how can i cause that by selecting a row
    the checkbox on this row will be also selected (shown as checked)?
    So this is the coding in the eventhandlermethod on onselect property of the table:
    METHOD onactionmark_cb .
      DATA lo_nd_table_data TYPE REF TO if_wd_context_node.
      DATA lo_el_table_data TYPE REF TO if_wd_context_element.
      DATA ls_table_data TYPE wd_this->element_table_data.
      DATA lt_table_data TYPE wd_this->elements_table_data.
      DATA lt_set TYPE wdr_context_element_set.
    DATA lv_idx TYPE i.
    navigate from <CONTEXT> to <TABLE_DATA> via lead selection
      lo_nd_table_data = wd_context->get_child_node( name = wd_this->wdctx_table_data ).
    This would now contain the references of all the selected rows
      CALL METHOD lo_nd_table_data->get_selected_elements
        RECEIVING
          set = lt_set.
      LOOP AT lt_set INTO lo_el_table_data.
        " Use the references to get the exact row data
        CALL METHOD lo_el_table_data->get_static_attributes
          IMPORTING
            static_attributes = ls_table_data.
        APPEND ls_table_data TO lt_table_data.
        CLEAR ls_table_data.
      ENDLOOP.
    mark/shhow the checkboxes checkd in the selected rows
    ENDMETHOD.
    Thank you for any help
    Haleh
    Edited by: Haleh Mir Ashrafi on Nov 9, 2008 6:29 PM

    Hi Haleh,
    I tried replicating your requirement and have written below the exact working code for the same. I will try to explain you my component so that you can get to understand its functionality. I have 2 tables & 1 input field in my view. The user enters a customer number in the input field and presses on a button. This leads to the corresponding sales orders filled into the 1st table ui element. The user then selects multiple rows from this table and presses on a toolbar button to copy these selected rows to the 2nd table. Within the same event I also set the checkbox for the rows selected by the user in the 1st tables row to selected. Hope that this would meet your requirement. On pressing the button the system would check if the checkbox is enabled & then mark the selected rows checkboxes as selected and would also copy the rows to the 2nd table. If the checkbox is disabled then the system would neither set it as checked nor copy it to the 2nd table. The rest of the checkboxes for the rows which weren't selected by the user remain as unchecked.
    METHOD onactioncopy_selected_rows .
      DATA:  wd_node TYPE REF TO if_wd_context_node,
             ls_node1 TYPE ig_componentcontroller=>element_node1,
             lt_node1 TYPE ig_componentcontroller=>elements_node1,
             wa_temp  TYPE REF TO if_wd_context_element,
             lt_temp  TYPE wdr_context_element_set.
      wd_node = wd_context->get_child_node( name = 'NODE1' ).
      " Get all the context element information for the rows selected by the user
      CALL METHOD wd_node->get_selected_elements
        RECEIVING
          set = lt_temp.
      " Just get the reference of the 2nd table to which you want to copy selected rows
      wd_node = wd_context->get_child_node( name = 'NODE2' ).
      LOOP AT lt_temp INTO wa_temp.
        CALL METHOD wa_temp->get_static_attributes
          IMPORTING
            static_attributes = ls_node1.
        " Check if the checkbox is disabled/enabled. The "enabled" property of the checkbox
        " is bound to the boolean context attribute by name ENABLED
        IF ls_node1-enabled EQ abap_true.
          wa_temp->set_attribute( EXPORTING name  = 'CHECKBOX'
                                            value = abap_true ).
          APPEND ls_node1 TO lt_node1.
          CLEAR ls_node1.
        ENDIF.
      ENDLOOP.
      " Bind the rows selected by the user to the 2nd table ui element
      wd_node->bind_table( new_items = lt_node1 ).
    ENDMETHOD.
    I have checked your code where you say like:
    IF elem_test->is_selected( ) = abap_true AND stru_test-enabled = abap_false.
    You had earlier fetched the entire elements list using the get_elements method of if_wd_context_node & then checking each 1 of them individually to determine whether it was selected or not using the method id_selected. You can directly get only the elements which were selected by the user by using the method get_selected_elements instead. So now you will only have to check whether the checkbox field in that particular row is disabled/enabled. You now don't have to combine 2 conditions using AND & check them within the loop.
    Regards,
    Uday

  • Populating checkbox  with selected

    I am trying to figure out how to display whether a user has selected an item in a checkbox. This requires two queries, one to get the locations and the second to check if the user has selected the location or not.
    I just dont know how to loop through both of these queries to add "SELECTED" to the checkbox fields.
    Code below only works if the user has selected one item previously. If more than one item, each location is listed twice, but the correct items are checked.
    <%
    String locations_query = "SELECT * FROM Client_Location WHERE Client_ID= '"+ Client_ID_form +"'";
    ResultSet locations_myResultSet = stmt.executeQuery(locations_query);
             while (locations_myResultSet.next()) {
                String locations_Location_ID = locations_myResultSet.getString("Location_ID");
         %>
    <%
    String cust2_query = "SELECT Location_ID, Location_Name FROM Customer_Locations ORDER BY Location_Name";
    ResultSet cust2_myResultSet = stmt.executeQuery(cust2_query);
             while (cust2_myResultSet.next()) {
               String Location_Name = cust2_myResultSet.getString("Location_Name");
               String Location_ID = cust_myResultSet.getString("Location_ID");
         %>
        <TR>
        <td align="right"></td>
        <TD><input type=checkbox value="<%=Location_ID%>" name="location_list"<%if(locations_Location_ID.equals(Location_ID)){%> checked<%}%>><%=Location_Name%></td>
        </tr>
         <%
           cust2_myResultSet.close();
    %>
         <%
           locations_myResultSet.close();
    %>Thank you for your time.

    Not worked on jsp. however in java, a checkbox is either selected or not selected, so you can use checkboxitem.isSelected().

  • Putting a check box above column for selection in WD ALV

    Hi,
    Can anyone provide me a code snippet and help me how I can
    provide a check box above column for selection in WD ALV.
    Best Regards
    Sid

    Hi Sid,
    As far as I know we cannot put checkboxes directly above the Column headers.
    You can achieve this functionality in a round above method
    You can create a group of checkboxes above your ALV table with names of  columns to be selected beside each check box and proceed with your further processing.
    Also If you are just looking at which columns you need to select to be shown on the
    ALV output
    data: lr_standard_functions type ref to if_salv_wd_std_functions.
    lr_standard_functions ?= wd_this->r_table.
    lr_standard_functions->set_column_selection_allowed( ' ' ).
    Hope this is of some help.
    Regards,
    Ismail.
    Edited by: Ismail Basha on Jan 23, 2008 1:47 PM
    Edited by: Ismail Basha on Jan 24, 2008 3:23 AM

Maybe you are looking for

  • Can't install Windows 7 with Boot Camp...

    When i want to install Windows 7 and I proceed the first steps, after creating a partition for Windows an error occurs that says Boot Camp Assist quit unexpedtedly, Does anyone have any idea for fixing this problem? I've heard I should reinstall the

  • SMTP service failure

    I have been quite happy with JES messaging server 2005Q4 until recently. The other night SMTP service failed at around 1:04am. I had to restart the processes using "imsimta restart". Then, last night, the same thing happened again but this time at 1:

  • SQLJ : sending refcursors via out parameters of PL/SQL functions possible ?

    Hello, in SQLJ it's possible to get a refcursor back from a PL/SQL function via the return value(the usual case in the online examples). Is it also possible to give a refcursor back via an out parameter so that the return value could be used for othe

  • Document Number Assignment.

    Hi Guru's Am a newbee in this mySAP PLM area and have a question regarding Number Assignment. I have a small scenario. Company "S" aquired companies A,B,C & D. All companies were following thier own ways of generating new part numbers.Now the task is

  • Out of Environment Space

    Hello all, I have spent quite some time reading through the installation manuals, readmes and such. I have installed the J2sdkee1.2.1 and jdk1.3.1_01 and the petstore application 1.1.2 . I am running Win98 (500mhz 256 ram) Now that i have them instal