Template
</> Source
<!DOCTYPE html>
<html>
<head>
<title>Template</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<link rel="stylesheet" type="text/css" href="../../../codebase/fonts/font_roboto/roboto.css"/>
<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlx.css"/>
<script src="../../../codebase/dhtmlx.js"></script>
<style>
div.simple_bold,
div.simple_link {
padding: 2px 0px 1px 0px;
margin: 2px 0px 2px 0px;
font-family: Roboto, Arial, Helvetica;
font-size: 14px;
color: #404040;
}
div.simple_bold {
font-weight: 500;
}
</style>
<script>
var myForm, formData, t=false;
function doOnLoad() {
formData = [
{type: "settings", position: "label-left", labelWidth: 100},
{type: "template", name: "product", label: "Product:", value: "dhtmlxForm", format:format_a},
{type: "template", name: "link", label: "Visit our site:", value: "dhtmlx.com", format:format_a},
{type: "template", label: "Advanced:", value: "Click me!", format:format_b}
];
myForm = new dhtmlXForm("myForm", formData);
}
function format_a(name, value) {
if (name == "product") return "<div class='simple_bold'>"+value+"</div>";
if (name == "link") return "<div class='simple_link'><a href='http://"+value+"' target='blank'>"+value+"</a></div>";
}
function format_b(name, value) {
// to access form instance from format function
// you cann use the following method:
// var form = this.getForm();
return "<div class='simple_link'><a href='javascript:void(0);' onclick='custom_func();'>"+value+"</a></div>";
}
function custom_func() {
t = !t;
myForm.forEachItem(function(name){
myForm.setItemLabel(name, (myForm.getItemLabel(name))[t?"toLowerCase":"toUpperCase"]());
});
}
</script>
</head>
<body onload="doOnLoad();">
<div id="myForm" style="height:100px;"></div>
</body>
</html>
Documentation
Check documentation to learn how to use the components and easily implement them in your applications.