{"id":358,"date":"2011-09-08T18:38:54","date_gmt":"2011-09-08T18:38:54","guid":{"rendered":"http:\/\/www.sitekickr.com\/blog\/?p=358"},"modified":"2011-09-08T18:38:54","modified_gmt":"2011-09-08T18:38:54","slug":"generating-safe-valid-id-attributes","status":"publish","type":"post","link":"https:\/\/www.sitekickr.com\/blog\/generating-safe-valid-id-attributes\/","title":{"rendered":"Generating safe, valid id attributes"},"content":{"rendered":"<p>Depending on your circumstances, it may not be straightforward to generate unique or valid id&#39;s for your HTML elements. If you are looping over database records, you&#39;d normally involve your records primary key in the ID attribute. But, if your primary key is not unique, or is not of a numeric datatype this method isn&#39;t as simple.<\/p>\n<p>One of the most basic methods to deal with this is to use your scripting languages Base64 conversion function.<\/p>\n<p>ColdFusion Example:<\/p>\n<p><code>&lt;cfoutput&gt;&lt;label for=&quot;#ToBase64(primary_key_value &amp; secondary_key_value)#&quot;&gt;#option_label#&lt;\/label&gt;&lt;\/cfoutput&gt;<br \/>\n\t<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Depending on your circumstances, it may not be straightforward to generate unique or valid id&#39;s for your HTML elements. If you are looping over database&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"amp_status":""},"categories":[34,14],"tags":[],"_links":{"self":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/358"}],"collection":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/comments?post=358"}],"version-history":[{"count":0,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/358\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/media?parent=358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/categories?post=358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/tags?post=358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}