0

I want to ensure that when I check a certain box then another checkbox will be checked and unable to uncheck unless the master checkbox is deselected. When the ECOM checkbox is checked the 3d secure checkbox is automatically checked and cannot be unchecked until the Ecom box is deselected.

<%
                    If Request.QueryString("ECOM") = "ON" Then
                        Apply_ECOM_Check.Checked = True
                    End if  
                    If Request.QueryString("MOTO") = "ON" Then
                        Apply_MOTO_Check.Checked = True
                    End if  
                    If Request.QueryString("TERMINAL") = "ON" Then
                        Apply_TERMINAL_Check.Checked = True
                    End if 

                    If Apply_ECOM_Check.Checked = False and Apply_MOTO_Check.Checked = False and Apply_TERMINAL_Check.Checked = False then
                        Apply_ECOM_Check.Checked = True
                    End if


                  %>

 <script type="text/javascript">

function enableaddonservice() {

        var ecom =document.getElementById("Apply_ECOM_Check").checked;
        var moto =document.getElementById("Apply_MOTO_Check").checked;
        var terminal =document.getElementById("Apply_TERMINAL_Check").checked;

        if (ecom==true ) {
            document.getElementById("addonservices").style.display = "block";
        } else {
            document.getElementById("addonservices").style.display = "none";
        }
    }


var chk1 = $('#Apply_ECOM_Check');
var chk2 = $('#Apply3DSecure');

//check the other box
chk1.on('click', function(){
  if( chk1.is(':checked') ) {
    chk2.attr('checked', true);
  } else {
    chk2.attr('checked', false);
  }
});</script>

               <input class="noborder" type="checkbox" ID="Apply_ECOM_Check" name="Apply_ECOM_Check" runat="server" style="width: 18px" value="ON" onClick="enableaddonservice();" /> ECOM &nbsp;&nbsp;
               <input class="noborder" type="checkbox" ID="Apply_MOTO_Check" name="Apply_MOTO_Check" runat="server" style="width: 18px" value="ON" onClick="enableaddonservice();" /> MOTO &nbsp;&nbsp;
               <input class="noborder" type="checkbox" ID="Apply_TERMINAL_Check" name="Apply_TERMINAL_Check" runat="server" style="width: 18px" value="ON" onClick="enableaddonservice()" /> TERMINAL

Once Ecom is selected above then the 3d secure below is automatically selected and can not be removed unless ecom is deselected

<table style="width: 100%">
                      <tr>
                          <td><input class="noborder" type="checkbox" ID="Apply3DSecure" name="Apply3DSecure" runat="server" style="width: 18px"  /> 3D Secure&nbsp;&nbsp; </td>
                          <td> <input class="noborder" type="checkbox" ID="Apply_Mobilepaypage" name="Apply_Mobilepaypage" runat="server" style="width: 18px"  /> Mobile PayPage &nbsp;&nbsp; </td>
                          <td> <input class="noborder" type="checkbox" ID="Apply_RepeatPayments" name="Apply_RepeatPayments" runat="server" style="width: 18px"  /> Repeat Payments &nbsp;&nbsp;</td>
                      </tr>

The Java script works on it's own with the check boxes but because the 3d secure selection addon is only displayed when Ecom is selected. I think that interferes. I have tried many functions in these check boxes and it will not do anything.

1 Answers1

0

The code you posted does not match the functionality that you ask for in your question so I am providing code for what you asked for when you say "When the ECOM checkbox is checked the 3d secure checkbox is automatically checked and cannot be unchecked until the Ecom box is deselected."

You will need two asp text boxes as follows:

<asp:CheckBox ID="Ecom" runat="server" AutoPostBack="true" />
<asp:CheckBox ID="threed" runat="server" AutoPostBack="true" Enabled="False" />

Now in the code behind you will need this code:

Private Sub Ecom_CheckedChanged(sender As Object, e As EventArgs) Handles Ecom.CheckedChanged
        If Ecom.Checked = True Then
            threed.Checked = True
        ElseIf Ecom.Checked = False Then
            threed.Enabled = True
        End If
    End Sub

I hope this helps.

Jamie
  • 555
  • 3
  • 14