Работа обьектов
Как так?поч undefined не могу понять, с полями все норм
var ooo = {
text: document.getElementById("size").value,
text1: document.getElementById("ingr").value
}
function Pizza (large,ingr) {
this.large = large;
this.ingr = ingr;
}
Pizza.prototype.size = function () {
if (this.large == "big") {
var cost = 25;
return cost;
}
if (this.large == "medium") {
var cost = 15;
return cost;
}
if (this.large == "small") {
var cost = 5;
return cost;
}
}
Pizza.prototype.costr = function () {
var cost = this.size();
if (this.ingr == "mashroms") {
var rez = 15 + cost;
// var b = document.createElement('p');
// b.innerHTML = rez;
// document.body.appendChild(b);
return rez;
}
if (this.ingr == "olives") {
var rez = 25 + cost;
console.log(rez);
return rez;
}
}
var bro = new Pizza(ooo.text,ooo.text1);
document.getElementById('but').onclick = function () {
var er = bro.costr();
var b = document.createElement('p');
b.innerHTML = er;
document.body.appendChild(b);
}
|