pi.element.environment.getValue
Summary
Returns value of the given element.Input ve Textarea elementlerinin value attribute'unu, Select elementlerin secili option'inin degerini, geri kalanlarda innerHTML degerini dondurur.
Syntax
element.environment.getValue(element);
Usage Example
>>> pi.util.Element.getValue(username);
"angelinaJolie"
Examples
Example #1: Create a form that contains input, textarea and select elements and print contents of these elements when user click to a button.
Source files of the above example:
../../getValue.html
<div id="form"></div>
<hr />
<div id="container"></div>
../../getValue.js
var name,message,color;
function get(){
pi.get("container").innerHTML = [
name.environment.getValue(),
message.environment.getValue(),
color.environment.getValue(),
].join("<br />");
};
pi.util.Init.push(function(){
name = new pi.element("input").insertAfter(
new pi.element("label").update("Name:").insert(pi.get("form"))
);
new pi.element("BR").insertAfter(name);
message = new pi.element("textarea").insertAfter(
new pi.element("label").update("Message:").insert(pi.get("form"))
);
new pi.element("BR").insertAfter(message);
color = new pi.element("select").child.add(
new pi.element("option").attribute.set("value","RED").update("Red"),
new pi.element("option").attribute.set("value","Green").update("Green"),
new pi.element("option").attribute.set("value","Blue").update("Blue")
).insertAfter(
new pi.element("label").update("Color:").insert(pi.get("form"))
);
new pi.element("BR").insertBefore(
new pi.element("button").event.addListener("click",get).update("Get Values").insertAfter(color)
);
});