javascript 动态更新目录项标签

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 动态更新目录项标签相关的知识,希望对你有一定的参考价值。

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}
	
	var ga = new GlideAjax('HRCatalogAJAX');
	ga.addParam('sysparm_name', 'getLabel');
	ga.addParam('sysparm_cat_item', g_form.getUniqueValue());
	ga.addParam('sysparm_country', g_form.getValue('country'));
	ga.getXML(ajaxResponse);
	
	function ajaxResponse(response) {
		var answer = response.responseXML.documentElement.getAttribute("answer");
		
		answer = JSON.parse(answer);
		
		for (var prop in answer) {
			g_form.setLabelOf(prop, answer[prop]);
		}
	}
}
var HRCatalogAJAX = Class.create();
HRCatalogAJAX.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
	
	getLabel: function() {
		
		var obj = {};
		
		var catItem = this.getParameter('sysparm_cat_item');
		var country = this.getParameter('sysparm_country');
		
		var gr = new GlideRecord('sn_hr_core_language_translation');
		gr.addQuery('u_catalog_item', catItem);
		gr.addQuery('u_country', country);
		gr.query();
		
		while(gr.next()) {
			obj[gr.u_variable.name.getDisplayValue()] = gr.u_field_label.getDisplayValue();
		}
		
		//Return as JSON String
		return JSON.stringify(obj);
	},

    type: 'HRCatalogAJAX'
});

以上是关于javascript 动态更新目录项标签的主要内容,如果未能解决你的问题,请参考以下文章

前端领域高频笔试面试—— JavaScript相关

如何在word中指定范围,在指定位置自动生成目录?

更新的依赖项和 Thymeleaf 标签不起作用

JavaScript 使用javascript动态IMG(标签)

Xamarin 将 ListView 项动态更新到 GUI

动态更新标签