Disable a data list from javascript

0

From a function, I am conditioning that with a check a data list that I have declared in a php file is enabled or disabled.

The data list is named dlClient :

And in my role I am doing the following:

$("#chkNewProspect").click(function()
    {
        var checked_status = this.checked;

        if (checked_status == true)
        {
            document.getElementById("dlClient").disabled = true;
        }
        else
        {
            document.getElementById("#dlClient").disabled = false;
        }
    });

But I do not succeed in deactivating said datalist. Has anyone had a similar experience?

<input list="dlClient" class='col-lg-12' style='height:35px' enabled> 
<?php datalistCliente("dlClient",1,2); ?> –

This code is in PHP and retrieves a list, works great, but in a file with JavaScript functions for the Main try through the click function (For the CheckBox) disable the data list. From there I use an input type text that I have also in PHP and it works perfectly to deactivate it, what I do not achieve is that I do it for both, I paste complete code:

$("#chkNewProspect").click(function()
    {
        var checked_status = this.checked;

        if (checked_status == true)
        {
            $("#txtNewProspect").removeAttr("disabled");
            document.getElementById("dlClient").disabled = true;
        }
        else
        {
            $("#txtNewProspect").attr("disabled", "disabled");
            // document.getElementById("#dlClient").disabled = false;
        }
    });
    
asked by Carlos Alberto Alcocer Juárez 28.12.2018 в 17:52
source

0 answers