des pues de varios intento no he logrado hacerlo funcionar para trabajar con una sola función, actualizo el post con lo que tengo hasta el momento:
Script
Código Javascript
:
Ver original<script type="text/javascript">
function calcula1(){
var operf1 = document.getElementById("pfrs");
var operando1 = operf1.selectedIndex;
var ope1 = operf1.options[operando1];
var pfrs = ope1.value;
document.form1.frs.value = pfrs;
document.form1.pfrs.disabled=this.value!='';
}
function calcula2(){
var operf2 = document.getElementById("pdes");
var operando2 = operf2.selectedIndex;
var ope2 = operf2.options[operando2];
var pdes = ope2.value;
document.form1.des.value = pdes;
document.form1.pdes.disabled=this.value!='';
}
function calcula3(){
var operf3 = document.getElementById("psab");
var operando3 = operf3.selectedIndex;
var ope3 = operf3.options[operando3];
var psab = ope3.value;
document.form1.sab.value = psab;
document.form1.psab.disabled=this.value!='';
}
var global= new Array(0, 0, 0, 0, 0);
function statpoint(elemSelect, indiceArray){
var pointset= parseInt(elemSelect.options[elemSelect.selectedIndex].text);
var datpast= global[indiceArray];
var atrset= document.getElementById("atr");
var atrpoint= parseInt(atrset.value);
atrpoint=atrpoint-datpast;
atrset.value=atrpoint+pointset;
global[indiceArray]=pointset;
}
</script>
Codigo html select options y mas:
Código HTML:
Ver original<form name="form1" method="post" id="form1" action="nchar.php" > <select id="pfrs" name="pfrs" size="1" onchange="calcula1(this.options.selectedIndex);statpoint(this, 0)"> <input type="text" name="frs" id="frs" value="10" maxlength="3" size="4" readonly="readonly"/> <select id="pdes" name="pdes" size="1" onchange="calcula2(this.options.selectedIndex);statpoint(this, 1)"> <input type="text" name="des" id="des" value="10" maxlength="3" size="4" readonly="readonly" /> <select id="psab" name="psab" size="1" onchange="calcula3(this.options.selectedIndex);statpoint(this, 2)"> <input type="text" name="sab" id="sab" value="10" maxlength="3" size="4" readonly="readonly" /> <select id="pvig" name="pvig" size="1" onchange="calcula4(this.options.selectedIndex);statpoint(this, 3)"> <input type="text" name="vig" id="vig" value="10" maxlength="3" size="4" readonly="readonly" /> <select id="pesp" name="pesp" size="1" onchange="calcula5(this.options.selectedIndex);statpoint(this, 4)"> <input type="text" name="esp" id="esp" value="1" maxlength="3" size="4" readonly="readonly" /> <input name="atr" id="atr" value="0" readonly="readonly" />
agradezco si alguien puede aportar algo a como simplificar el código javascript