embedding multiple values in options of tag? – AJ. Jun 06 '12 at 18:19

  • What's the IE support for dataset? Does the --- [here](https://developer.mozilla.org/en/DOM/element.dataset) mean any version? No version (!!) ? (+1 for the json idea, btw) – Adam Rackis Jun 06 '12 at 18:24
  • No am not using jquery just plain HTML. – AJ. Jun 06 '12 at 18:24
  • @Adam Rackis check [here](http://stackoverflow.com/questions/2412947/do-html5-custom-data-attributes-work-in-ie-6) about dataset and the horror in IE6 :) I think the getAttribute() works with ANY attribute, but to works clearly with data-sets the html5 (+doctype) is needed. –  Jun 06 '12 at 18:33
  • @Adam Rackis, i dont know what the -- value means but i suspect total lack of support? just tested on IE9, total failure, doctyped also. –  Jun 06 '12 at 18:43
  • @vlzvl - I think you're right. I just couldn't imagine IE9 not supporting this. Guess I was wrong. Wow. – Adam Rackis Jun 06 '12 at 19:10
  • @vlzvl I am getting "SyntaxError: Unexpected end of input" on this line: var option_value = JSON.parse(obj.options[obj.selectedIndex].value); – AJ. Jun 07 '12 at 16:37
  • no - JSON.parse exists in [most](http://caniuse.com/json) browser versions. What value the obj.options[obj.selectedIndex].value has? Perhaps some missing brackets will trigger this error. –  Jun 07 '12 at 16:51
  • I have included JSON JavaScript libraries as well. – AJ. Jun 07 '12 at 16:51
  • I am getting "{" in alert window. – AJ. Jun 07 '12 at 16:53
  • GOT IT. I was using double quotes to enclose json object. – AJ. Jun 07 '12 at 16:59
  • 1
    yes, this is common error. JSON uses double quotes to encapsulate data which you must use single quotes to encapsulate the whole json object into html attribute; or one could escape the inner quotes; i prefer the first. –  Jun 07 '12 at 17:02
  • 1

    I would render the options like this:

    <option data-value1="X" data-value2="Y">
    

    Then deal with these data- attributes however you want (with jQuery's data("value1") method, with the native getAttribute("data-value1"), etc.

    Adam Rackis
    • 82,527
    • 56
    • 270
    • 393
    • No - data-foo attributes are recognized in any browser -- even ie 6. Having said that, getAttribute has some limitations in support, so you'd either have to use jQuery, or possibly the dataset collection like vlvl said (which I think has better support) – Adam Rackis Jun 06 '12 at 18:21