I wish to populate html input boxes with the data-id from certain elements.
<h2 class="postItem" data-id="23" href="#"></h2>
This an example of a H2 element I have in my site, what I wish to do is take this data-id and place it in a input box.
I am using JavaScript/MooTools to grab the data-ids see this Fiddle
$$('.postItem').addEvent('click', function(e){
var el = e.target;
var id = el.getAttribute('data-id');
alert(id);
});
So my question is how do I then take this data-id and place it inside of a input box?
I think you mean this.
Just one simple line:
$('melp').value = id;
With melp
of course being the id
of the input element.