Variable Values - alert/document.write

by chayacooper

HTML

<input id="Shoulders1" type="text" value="Too_small">
<br/>
<br/>
<select name=Shoulders id="Shoulders">
    <option data-value="null" value="null">Select</option>
    <option data-value="Too_small" checked value="Too_small">Too Small</option>
    <option data-value="Too_big" value="Too_big">Too Big</option>
    <option data-value="Too_expensive" value="Too_expensive">Too expensive</option>
</select>

JavaScript

// Works for text box, but not select element
// Switch to change function
var Shoulders = $("#Shoulders1").val();
if (Shoulders === "Too_small") {
    alert("Shoulders: Too small");
}

var mytext = "Hello again";
if (mytext === "Hello again") {
    alert(mytext);
    //document.write is disallowed in jsfiddle and might break the fiddle
    //document.write(mytext);
}

var add = function (x, y) {
    this.val = x + y;
},    
obj = { val: 3 };
add.apply(obj, [2, 8]);
alert(obj.val);