//<!-- ###### EDIT THIS javascript TO CUSTOMISE THE FORM -->
/*
set_file
chk
validate
setDispFld
doExecute
*/
function set_file(form,src,target){
form.elements[target].value = form.elements[src].value;
} //set_file
function chk(obj){
var opt_node;
if (obj.nodeName.toLowerCase() == 'select'){
opt_node = obj.name+'_opt';
obj.form.elements[opt_node].value = obj.options[obj.selectedIndex].text;
}
else {
opt_node = obj.parentNode.name+'_opt';
obj.form.elements[opt_node].value = obj.text;
}
} //chk
function validate() {
return true;
} //validate
function setDispFld(form,fld,val){
sel = form.elements[fld];
sel.value = val;
psel = sel.parentNode;
// as a default, formDef.xsl create a div section:
div1 = psel.getElementsByTagName("div")[0];
if (div1 != undefined)
psel.removeChild(div1);
// create a span section
div2 = psel.getElementsByTagName("span")[0];
if (div2 != undefined)
psel.removeChild(div2);
div2 = document.createElement("span");
div2.innerHTML = val;
psel.appendChild(div2);
return div2;
} //setDispFld
function doExecute(form,v1,v2,op,disp_fld)
{
var res;
var var1 = Number(form.elements[v1].value); // variable 1 value
var var2 = Number(form.elements[v2].value); // variable 2 value
var vop = form.elements[op+'_opt'].value; // selected operation
//alert('doExecute: '+v1+'--'+var1+'--'+v2+'--'+var2+'--'+vop);
switch(vop){
case '+':
res = var1+var2;
break;
case '-':
res = var1-var2;
break;
case '*':
res = var1*var2;
break;
case '/':
res = var1/var2;
break;
default:
res = 0;
}
// create a display field near disp_fld
//alert('doExecute: '+res+'--'+disp_fld);
setDispFld(form,disp_fld,res);
} //doExecute
|