0

USE CASE

I want each one of the (3) users -- Marty, Reggie, and Rust -- to be able to click a button in order to dynamically place a check mark on a multiple selection CHOICE field on the Edit Form. The display and internal name(s) of the choice field is confirmChoice, and the choice options are as follows:

  • Marty
  • Reggie
  • Rust
  • All

Since this is a multiple-selection choice field, I want to create 8 buttons whose value(s) correspond with the choices above:

<button type="button" id="btnMarty" onclick="checkMarty()"> Marty YES</button> <button type="button" id="btnMarty" onclick="uncheckMarty()"> Marty NO</button> <button type="button" id="btnReggie" onclick="checkReggie()"> Reggie YES</button> <button type="button" id="btnReggie" onclick="ucheckReggie()"> Reggie NO</button> <button type="button" id="btnRust" onclick="checkRust()"> Rust YES</button> <button type="button" id="btnRust" onclick="ucheckRust()"> Rust NO</button> <button type="button" id="btnAll" onclick="checkAll()"> All YES</button> <button type="button" id="btnAll" onclick="uncheckAll()"> All NO</button>

When a button is pushed, the choice option corresponding with the button value will get checked without a page refresh or submit THIS ISN'T A PRE-SAVE ACTION. The user will have to manually click 'Submit/save' when they're finished updating the form.

EXAMPLE

Marty accesses the Edit Form. He clicks the 'Marty' button (whose value is 'MartyConfirm', and the choice 'MartyConfirm' gets a check-mark. When Marty pushed the 'All' button, the choice 'All' gets a check-mark.

I know there's an exisitng OOB 2010 approval WF, but I'd rather avoid SPD if possible. Is there a way to do this?

1 Answer 1

1

Sample script for your reference(not complete, I believe you can achieve base on sample script).

Insert script editor webpart to edit form and then insert the script to script editor web part.

<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script type="text/javascript">
        function checkMarty() {
            var MartyCheck = $("label:contains('Marty')").siblings("input");
            if (!MartyCheck.prop('checked')) {
                MartyCheck.prop('checked', true);
            }
        }
        function uncheckMarty() {
            var MartyCheck = $("label:contains('Marty')").siblings("input");
            if (MartyCheck.prop('checked')) {
                MartyCheck.prop('checked', false);
            }
        }
        function checkAll() {
            var MartyCheck = $("table[id*='confirmChoice']").find('input').each(function () {
                if (!$(this).prop('checked')) {
                    $(this).prop('checked', true);
                }
            })

        }
        function uncheckAll() {
            var MartyCheck = $("table[id*='confirmChoice']").find('input').each(function () {
                if ($(this).prop('checked')) {
                    $(this).prop('checked', false);
                }
            })

        }
    </script>
    <button type="button" id="btnMarty" onclick="checkMarty()"> Marty YES</button>
    <button type="button" id="btnMarty" onclick="uncheckMarty()"> Marty NO</button>
    <button type="button" id="btnReggie" onclick="checkReggie()"> Reggie YES</button>
    <button type="button" id="btnReggie" onclick="ucheckReggie()"> Reggie NO</button>
    <button type="button" id="btnRust" onclick="checkRust()"> Rust YES</button>
    <button type="button" id="btnRust" onclick="ucheckRust()"> Rust NO</button>
    <button type="button" id="btnAll" onclick="checkAll()"> All YES</button>
    <button type="button" id="btnAll" onclick="uncheckAll()"> All NO</button>

Update:

The script use jQuery attribute selector, so make sure the choices table element id matches.

enter image description here

3
  • Thanks for the quick response. The Marty functions worked perfectly! The check/uncheck all did not seem to work, though. If it's a quick fix, would you let me know your thoughts? You really, really, really helped me out here. Thanks.
    – TheJDScott
    Aug 21, 2018 at 15:23
  • 1
    Check my update.
    – Lee_MSFT
    Aug 22, 2018 at 1:14
  • Is there a way to add functionality to allow .btn to show or be hidden based on the checkbox values on page load, as well?
    – TheJDScott
    Dec 12, 2018 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.