Set value in Radiobutton - Javascript

Comments

6 comments

  • Avatar
    Jean-Sébastien Renaud

    Use this Javascript method :  documentation.agilepoint.com/8000/appbuilder/cloudjsSetFieldValue.html

    So you can build a function kind of like this : 
    function fn_Approve(Approved){
    var options = {};
    options.fieldId = '[Internal Name of Radio button]'; 
    options.value = Approved

    eFormHelper.setFieldValue(options, function (result)
      {
      if (result.isSuccess) //check if is success
        { 
        console.log(result.data); //logs the data holds empty object
        }
      else 
        {
        console.log(result.error); //logs the error
        }
    });
    };

    Then on your Approve button you set the Javascript function to : fn_Approve(1);
    And on your Reject Button :  fn_Approve(0);

     

    0
    Comment actions Permalink
  • Avatar
    Christian Del Angel

    Thank you Jean,

    This worked for me with a first execution, only that I do not see the value sent in my radio reflected, it is necessary to add the line
    $("#ApproveFlow").val(value);?

    0
    Comment actions Permalink
  • Avatar
    Jean-Sébastien Renaud

    On the following line of the Javacript function, if you replace [Internal Name of Radio button] with the proper internal name of your radio button, as soon as you click the buttons, the radio button should change value.

    options.fieldId = '[Internal Name of Radio button]'; 

    The "eFormHelper.setFieldValue " method in the function is taking care of changing the radio button value.

    0
    Comment actions Permalink
  • Avatar
    Christian Del Angel

    Change the name to the one I'm using

    function clickApprove(value){

      debugger;       

      var options = {};

                    options.fieldId = 'ApproveFlow'; // individual control

                    options.value = value;

                    eFormHelper.setFieldValue(options, function (result)

                    {

                        if (result.isSuccess) //check if is success

                    {

                       console.log(result.data); //logs the data holds empty object

                    }

                    else

                    {

                        console.log(result.error); //logs the error

                    }

                    });

                   

                    //Se asigna valor Approve(1)/Reject(0)

                 if(value == "0")

                    {

                                   debugger;

          $("#Return_Reject").prop('disabled', false);

                    }

                    else

                    {  

                    }

    }

    My html is 

    <table>\

            <tr>\

              <td>\

               <input id="Approve" class="field Button ButtonOriginal BlueButton"\

                  style="font-family: Arial; font-size: 12px; font-style: normal; font-weight: normal; text-decoration: none; min-width: 80px;"\

                  type="button" value="Approve" onclick="clickApprove(1)" ></input>\

              </td>\

              <td>\

                <input id="Reject" class="field Button ButtonOriginal BlueButton"\

                  style="font-family: Arial; font-size: 12px; font-style: normal; font-weight: normal; text-decoration: none; min-width: 80px;"\

                  type="button" value="Reject" onclick="clickApprove(0)" ></input>\

              </td>\

            </tr>\

    </table>\

    0
    Comment actions Permalink
  • Avatar
    Christian Del Angel

    I already found my error, it was in the html, the code works for me, thank you very much, Jean

    0
    Comment actions Permalink
  • Avatar
    Jean-Sébastien Renaud

    Great ! :)

    0
    Comment actions Permalink

Please sign in to leave a comment.