Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6350065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:44:29+00:00 2026-05-24T21:44:29+00:00

The problem is to add a checkbox to a PHP/HTML_Quickform form that toggles a

  • 0

The problem is to add a checkbox to a PHP/HTML_Quickform form that toggles a password input from masked to unmasked and back. This can be done with JavaScript, but how to add the JavaScript code to the form and how to wire it to the form elements?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:44:30+00:00Added an answer on May 24, 2026 at 9:44 pm

    Well, the code can be added via a static Quickform element and the wiring can be done by means of attribute arrays.

    Here is the code for the form elements:

        $this->addElement('password', 'password', 'Password:', array('id'=>'id_password'));
        $this->addElement('checkbox', 'unmask', 'Unmask password:', '', array('onclick'=>'togglePasswordMask(\'id_password\')', 'id'=>'id_passwordunmask')); 
    

    and here is the code to add the JavaScript that does the job:

        $this->addElement('static', null, '', 
                '<script type="text/javascript">
                //<![CDATA[
                function togglePasswordMask(id) {
                    var pw = document.getElementById(id);
                    var chb = document.getElementById(id+\'unmask\');   
                    var newpw = document.createElement(\'input\');
    
                    newpw.setAttribute(\'name\', pw.name);
    
                    if (chb.checked) {
                        newpw.setAttribute(\'type\', \'text\');
                    } else {
                        newpw.setAttribute(\'type\', \'password\');
                    }
    
                    newpw.id = pw.id;
                    newpw.value = pw.value;
                    pw.parentNode.replaceChild(newpw, pw);
                }
                //]]>
                </script>');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple form: <form action=add.php method=post > <input name=name maxlength=30/><br/> <textarea cols=80 name=description
This is my checkbox HTML code <input id=termsCheckbox name=termsCheckbox type=checkbox value=terms <?PHP echo $terms;
There are a set of point that are collinear. The problem is to add
I'm experiencing this problem: I want to add the Google Maps API to my
I've encountered this problem (while trying to add SQL Server Database (.mdf) file to
html <button>a</button> <div class=headerer> <p>visit <a href=http://reigel-codes.co.cc>reigel-codes.co.cc</a></p> </div> problem how can I add checkbox
Ok, so I have this jquery function to that grabs the checkbox's value and
I'm in the process of writing a webpage (in PHP, though this problem does
I add all row CheckBox in my Gridview helping with this article . Here
I'm running into a problem where I have a simple add/edit form and using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.