Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    May 2012
    Posts
    20
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Add any custom attributes to input element

    Can I add any custom attributes on an input element?
    so If I have a regular checkbox

    Code:
    <input type='checkbox' name='mycheckbox1' > my checkbox
    be able to add attributes to use in javascript. Such as

    Code:
      <script language='javascript'>
    function doIt2(formname) {
      alert (formname.mycheckbox1.special);
    }
    </script>
      </head>
      <body>
    
    <input type='checkbox' name='mycheckbox1' special='xxxxx' onclick="doIt2(this)"> my checkbox 
       
      </body>
    </html>
    However this throws an error.
    Is something like this possible?

    thanks

  • #2
    Regular Coder dan-dan's Avatar
    Join Date
    Aug 2009
    Location
    England
    Posts
    483
    Thanks
    22
    Thanked 79 Times in 78 Posts
    Using HTML5 and javascript you can do this. Here is a detailed explaination including the use of the <input> tag.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •