JavaScript - Simple Enable Button Properties

Submitted by: 
Visitors have accessed this post 158 times.

In this tutorial we will create a Simple Enable Button Properties using JavaScript. JavaScript is a scripting or programming language that allows you to implement complex things on web pages. It is widely used in designing a stunning website. It is an interpreted programming language that has a capabilities of Object-Oriented. So Let's do the coding...

Getting started:

This is the link for the bootstrap that i used for the layout design

The Main Interface

This code contains the interface of the application. To create this just write these block of code inside the text editor and save this as index.html.

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1"/>
  5. <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/>
  6. <style >
  7. #container{
  8. width:500px;
  9. margin-left:auto;
  10. margin-right:auto;
  11. padding:5px;
  12. }
  13. .display{
  14. border:1px solid #ccc;
  15. overflow:scroll;
  16. overflow-x:hidden;
  17. height:150px;
  18. padding:10px;
  19. margin-bottom:40px;
  20. }
  21. </style>
  22. </head>
  23. <nav class="navbar navbar-default">
  24. <div class="container-fluid">
  25. <a class="navbar-brand" href="<a href="">Sourcecodester</a>
  26. " rel="nofollow">">Sourcecodester</a>
  27. </a> </div>
  28. </nav>
  29. <div class="col-md-3"></div>
  30. <div class="col-md-6 well">
  31. <h3 class="text-primary">JavaScript - Simple Enable Button Properties</h3>
  32. <hr style="border-top:1px dotted #ccc;"/>
  33. <div id="container">
  34. <h2>User Agreement</h2>
  35. <div class="display">
  36. These Terms will be applied fully and affect to your use of this Website. By using this Website, you agreed to accept all terms and conditions written in here. You must not use this Website if you disagree with any of these Website Standard Terms and Conditions.
  37. </div>
  38. <p><input type="checkbox" id="toggle"/> I agree with the terms and conditions.</p>
  39. <button class="btn btn-default" id="accept">Accept</button> <button class="btn btn-default">Decline</button>
  40. </div>
  41. </div>
  42. <script src="js/script.js"></script>
  43. </body>
  44. </html>

Creating the Script

This code contains the script of the application. This code will enable the button when only the checkbox is being checked. To do this just copy and write these block of codes as shown below inside the text editor and save it as script.js inside the js folder.

  1. var checkbox = document.getElementById("toggle");
  2. var accept = document.getElementById("accept");
  3. accept.disabled = true;
  4. checkbox.onchange = function(){
  5. accept.disabled = !this.checked;
  6. }

There you have it we successfully created a Simple Enable Button Properties using JavaScript. I hope that this simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.