(1) Click Event is not defined properly :
aCookie.onlclick = cookie.display();
// typing error onlclick
// cookie.display() actually it call display function, doesn't give reference
change to :
aCookie.onclick = cookie.display;
(2) set id "kind" to input box
(3) Current code set properties (id,kind,x,y) to instance of Cookie, not to element. Change code so that, the element is a parameter & set properties to it.
//pass element to set properties
function Cookie(elem,id, kind, x, y) {
elem.id = id;
elem.kind = kind;
elem.x = x;
elem.y = y;
this.display = function () {
alert("Cookie number: " + this.id + "; is a: " + this.kind + "; cookie : " +
" and it is situated on coordinates ; " + this.y + " and " + this.x + " on the cookie pan");
}
}
Fiddle : http://jsfiddle.net/aslancods/CzgLj/