How to display and change a text line

I have a dhtmlx form.

I would like to display a readonly text area whose content will change depending on what is loaded (for instance : “Data last modified on dd/mm/yy”).

I can get that data to be displayed dynamically as an input area (set to readonly), but it’s ugly and confusing.

I would like something flat like a “label”, unfortunately even when I give a name to a label I cannot modify its content using commands like myForm.setFormData() even though I can modify “input” fields in this fashion within an onBeforeDataLoad function.

So this

[code]…
{type:“label”, name:“modifiedDateTime”, label:"Going to contain data last modified on "},

myForm.setFormData({“modifiedDateTime”: "Data last modified on " + values.modifiedDateTime,…
[/code]
Has no effect, while the rest of the setFormData on “input” type fields works and the input fields are properly set…

Any suggestions?

Hi
You can try the next custom item type (based on the next sample: dhtmlx.com/docs/products/dht … ustom.html)

[code]

Custom item var myForm, formData; function doOnLoad() { formData = [ {type: "myItem", name: "test", my_text: "This is custom item"}, {type: "calendar", dateFormat: "%Y-%m-%d %H:%i", name: "start_date", label: "Start Date"} ]; myForm = new dhtmlXForm("myForm", formData); myForm.setItemLabel("test", "Data last modified on "); myCalendar = myForm.getCalendar("start_date"); myCalendar.attachEvent("onClick", function(d){ var newDate = myCalendar.getFormatedDate("%Y-%m-%d %H:%i", d); myForm.setItemLabel("test", "Data last modified on "+newDate); });
	}
	dhtmlXForm.prototype.items.myItem = {
		render: function(item, data) {
			item._type = "myItem";
			item.appendChild(document.createElement("DIV"));
			item.lastChild.innerHTML = data.my_text;
			this._custom_inner_func(item);
			return this;
		},
		destruct: function(item) {
			this._custom_inner_func2(item);
			item.innerHTML = "";
		},
		enable: function(item) {
			item.lastChild.style.color = "black";
			item._is_enabled = true;
		},
		disable: function(item) {
			item.lastChild.style.color = "gray";
			item._is_enabled = false;
		},
		_custom_inner_func: function(item) {
			item.lastChild.onclick = function(){
				if (this.parentNode._is_enabled) alert("Hello!")
			}
		},
		_custom_inner_func2: function(item) {
			item.lastChild.onclick = null;
		},
		setText: function(item, text) {
			item.lastChild.innerHTML = text;
			item.callEvent("onTextChanged",[item._idd,text]);
		},
		setValue: function(item, val) {
			item._value = val;
		},
		getValue: function(item) {
			return item._value;
		}
	};
	dhtmlXForm.prototype.setFormData_myItem = function(name, value) {
		return this.doWithItem(name, "setValue", value);
	};
	dhtmlXForm.prototype.getFormData_myItem = function(name) {
		return this.doWithItem(name, "getValue");
	};
</script>
[/code]

Thank Darya. I will try that. Your help is most useful (I like to know whether I missed something obvious).

Personally, I would think this could become a standard feature.

You are welcome!
If you need a text item in a form (like my provided one just to show some text) - you can left such request here:
viewforum.php?f=10