📄 tools.js
字号:
/*<!--dynamic create form elmente -->**/
function addField (form, fieldType, fieldName, fieldValue) {
if (document.getElementById) {
var input = document.createElement('INPUT');
if (document.all) { // what follows should work
// with NN6 but doesn't in M14
input.type = fieldType;
input.name = fieldName;
input.value = fieldValue;
}
else if (document.getElementById) { // so here is the
// NN6 workaround
input.setAttribute('type', fieldType);
input.setAttribute('name', fieldName);
input.setAttribute('value', fieldValue);
}
form.appendChild(input);
}
}
function getField (form, fieldName) {
if (!document.all)
return form[fieldName];
else // IE has a bug not adding dynamically created field
// as named properties so we loop through the elements array
for (var e = 0; e < form.elements.length; e++)
if (form.elements[e].name == fieldName)
return form.elements[e];
return null;
}
function removeField (form, fieldName) {
var field = getField (form, fieldName);
if (field && !field.length)
field.parentNode.removeChild(field);
}
function toggleField (form, fieldName, value) {
var field = getField (form, fieldName);
if (field)
removeField (form, fieldName);
else
addField (form, 'hidden', fieldName, value);
}
function setValue(oTarget, i){
var content = document.getElementById("div1").innerHTML;
content+="<input type=\"text\" name=\"propertys["+ i + "].name\" value=\"\">"
document.getElementById("div1").innerHTML=content;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -