Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Checkbox checked, disabled it

Community Beginner ,
Sep 23, 2021 Sep 23, 2021

Please, will you help me?

I need disable a checkbox with javascript after it has been selected, I did the next :

 

I selected a rows from Postgres DB for create the checkbox. I use a Perl languaje in Linux Centos 7, the code is next:

 

while(my $ref_alarm = $sth->fetchrow_hashref()) {

        ($gabinete)=$ref_alarm->{'gabinete'};

        ($alarma)=$ref_alarm->{'descrip_alarma'};

        print "<input type='checkbox' name='alarma' id='alarma' value='$alarma' onclick='alarma_reg(this.value);'/>$alarma</input>";

        print "<br>";

}

 

I had been use javascript for disable the checkbox that had been selected:

 

function alarma_reg(p_alarma) {

                //Get the checkbox

                document.getElementById("p_alarma").disabled = true;

                alarma_operada+=p_alarma + ',';

                document.getElementById("ver_alarmas").value=alarma_operada;

        }

 

But the option selected is not disable, please could you help me?

 

Regards

Xochitl

TOPICS
JavaScript
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 23, 2021 Sep 23, 2021

You want it to be 'readonly' if it's checked?

How do you check it, manually or with a code from somewhere else?

Do you have condition to uncheck it?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 24, 2021 Sep 24, 2021

You want it to be 'readonly' if it's checked?

Yes, when the user check the checkbox it's state must to change to disable o readonly.

 

How do you check it, manually or with a code from somewhere else?

I checked manually

 

Do you have condition to uncheck it?

The condition is, when it's selected  then change the checkbox state to disable.  So, the user will can't select anymore.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 23, 2021 Sep 23, 2021

Does you use a HTML form?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 24, 2021 Sep 24, 2021

Yes.  I had been use a HTML FORM.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 24, 2021 Sep 24, 2021
LATEST

You are posting in a wrong forum.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 24, 2021 Sep 24, 2021

Your script is not a regular PDF-JavaScript.

Place this script in the checkbox as a MouseUp action:

 

if (event.target.value) != "Off") {event.target.readonly = true;}


Acrobate du PDF, InDesigner et Photoshoptographe
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 24, 2021 Sep 24, 2021

Thanks for answered but sorry I don't what is a PDF-JavaScript.

 

Sorry.

Regards

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines