...

View Full Version : Add any custom attributes to input element



gregd101
05-21-2012, 11:50 PM
Can I add any custom attributes on an input element?
so If I have a regular checkbox



<input type='checkbox' name='mycheckbox1' > my checkbox


be able to add attributes to use in javascript. Such as




<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

dan-dan
05-22-2012, 12:15 AM
Using HTML5 and javascript you can do this. Here (http://blog.softlayer.com/2012/web-development-html5-custom-data-attributes/) is a detailed explaination including the use of the <input> tag.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum