Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/03/2012, 16:27
Avatar de spectrum4v12
spectrum4v12
 
Fecha de Ingreso: marzo-2012
Ubicación: Caracas - Venezuela
Mensajes: 1
Antigüedad: 12 años, 9 meses
Puntos: 0
Exclamación Problema con el combo box, necesito que actualice los caracteres solos.

Hola

Acabo de adaptar un codigo Javascript que encontre en internet a lo que necesito. La cuestion es que al seleccionar una opcion quisiera que NO saliera en el siguiente box la palabra "Seleccione una opcion" sino que automaticamente motrara la primera opción.

Aqui les dejo el codigo y ojalá puedan ayudarme.
Cita:
<script language="JavaScript" type="text/javascript">
<!--

/*
*** Multiple dynamic combo boxes
*** by Mirko Elviro, 9 Mar 2005
*** Script featured and available on JavaScript Kit (http://www.javascriptkit.com)
***
***Please do not remove this comment
*/

// This script supports an unlimited number of linked combo boxed
// Their id must be "combo_0", "combo_1", "combo_2" etc.
// Here you have to put the data that will fill the combo boxes
// ie. data_2_1 will be the first option in the second combo box
// when the first combo box has the second option selected


// first combo box

data_1 = new Option("1", "$");
data_2 = new Option("2", "$$");
data_3 = new Option("3", "$$$");


// second combo box

data_1_1 = new Option("33", "-");
data_2_1 = new Option("26", "--");
data_3_1 = new Option("21", "---");


// third combo box

data_1_1_1 = new Option("16mm - 3/8”", "*");
data_1_1_2 = new Option("20mm - ½”", "*");
data_1_1_3 = new Option("25mm - ¾”", "*");
data_1_1_4 = new Option("32mm - 1”", "*");
data_1_1_5 = new Option("40mm - 1 ¼”", "*");
data_1_1_6 = new Option("50mm - 1 ½”", "*");
data_1_1_7 = new Option("63mm - 2”", "*");
data_1_1_8 = new Option("75mm - 2 ½”", "*");
data_1_1_9 = new Option("90mm - 2 ½”", "*");
data_1_1_10 = new Option("110mm - 4”", "*");
data_1_1_11 = new Option("125mm - 5”", "*");
data_1_1_12 = new Option("160mm - 6”", "*");


data_2_1_1 = new Option("16mm - 3/8”", "*");
data_2_1_2 = new Option("20mm - ½”", "*");
data_2_1_3 = new Option("25mm - ¾”", "*");
data_2_1_4 = new Option("32mm - 1”", "*");
data_2_1_5 = new Option("40mm - 1 ¼”", "*");
data_2_1_6 = new Option("50mm - 1 ½”", "*");
data_2_1_7 = new Option("63mm - 2”", "*");
data_2_1_8 = new Option("75mm - 2 ½”", "*");
data_2_1_9 = new Option("90mm - 2 ½”", "*");
data_2_1_10 = new Option("110mm - 4”", "*");
data_2_1_11 = new Option("125mm - 5”", "*");


data_3_1_1 = new Option("16mm - 3/8”", "*");
data_3_1_2 = new Option("20mm - ½”", "*");
data_3_1_3 = new Option("25mm - ¾”", "*");
data_3_1_4 = new Option("32mm - 1”", "*");
data_3_1_5 = new Option("40mm - 1 ¼”", "*");
data_3_1_6 = new Option("50mm - 1 ½”", "*");
data_3_1_7 = new Option("63mm - 2”", "*");
data_3_1_8 = new Option("75mm - 2 ½”", "*");
data_3_1_9 = new Option("90mm - 2 ½”", "*");
data_3_1_10 = new Option("110mm - 4”", "*");
data_3_1_11 = new Option("125mm - 5”", "*");
data_3_1_12 = new Option("160mm - 6”", "*");



// fourth combo box

data_1_1_1_1 = new Option("1","%")
data_1_1_2_1 = new Option("1","%")
data_1_1_3_1 = new Option("1.7","%")
data_1_1_4_1 = new Option("1.7","%")
data_1_1_5_1 = new Option("2","%")
data_1_1_6_1 = new Option("2","%")
data_1_1_7_1 = new Option("2.5","%")
data_1_1_8_1 = new Option("2.3","%")
data_1_1_9_1 = new Option("2.8","%")
data_1_1_10_1 = new Option("3.4","%")
data_1_1_11_1 = new Option("3.8","%")
data_1_1_12_1 = new Option("4.9","%")


data_2_1_1_1 = new Option("0","%")
data_2_1_2_1 = new Option("0","%")
data_2_1_3_1 = new Option("0","%")
data_2_1_4_1 = new Option("0","%")
data_2_1_5_1 = new Option("0","%")
data_2_1_6_1 = new Option("0","%")
data_2_1_7_1 = new Option("0","%")
data_2_1_8_1 = new Option("2.9","%")
data_2_1_9_1 = new Option("3.5","%")
data_2_1_10_1 = new Option("4.2","%")
data_2_1_11_1 = new Option("4.8","%")
data_2_1_12_1 = new Option("6.1","%")


data_3_1_1_1 = new Option("0","%")
data_3_1_2_1 = new Option("0","%")
data_3_1_3_1 = new Option("1.7","%")
data_3_1_4_1 = new Option("1.7","%")
data_3_1_5_1 = new Option("2.3","%")
data_3_1_6_1 = new Option("2.4","%")
data_3_1_7_1 = new Option("3","%")
data_3_1_8_1 = new Option("3.6","%")
data_3_1_9_1 = new Option("4.3","%")
data_3_1_10_1 = new Option("5.3","%")
data_3_1_11_1 = new Option("6","%")
data_3_1_12_1 = new Option("7.7","%")





// other parameters


displaywhenempty=""
valuewhenempty=-1

displaywhennotempty="-Seleccione una opción-"
valuewhennotempty=0


function change(currentbox) {
numb = currentbox.id.split("_");
currentbox = numb[1];

i=parseInt(currentbox)+1

// I empty all combo boxes following the current one

while ((eval("typeof(document.getElementById(\"combo_"+i +"\"))!='undefined'")) &&
(document.getElementById("combo_"+i)!=null)) {
son = document.getElementById("combo_"+i);
// I empty all options except the first one (it isn't allowed)
for (m=son.options.length-1;m>0;m--) son.options[m]=null;
// I reset the first option
son.options[0]=new Option(displaywhenempty,valuewhenempty)
i=i+1
}


// now I create the string with the "base" name ("stringa"), ie. "data_1_0"
// to which I'll add _0,_1,_2,_3 etc to obtain the name of the combo box to fill

stringa='data'
i=0
while ((eval("typeof(document.getElementById(\"combo_"+i +"\"))!='undefined'")) &&
(document.getElementById("combo_"+i)!=null)) {
eval("stringa=stringa+'_'+document.getElementById( \"combo_"+i+"\").selectedIndex")
if (i==currentbox) break;
i=i+1
}


// filling the "son" combo (if exists)

following=parseInt(currentbox)+1

if ((eval("typeof(document.getElementById(\"combo_"+f ollowing+"\"))!='undefined'")) &&
(document.getElementById("combo_"+following)!=null )) {
son = document.getElementById("combo_"+following);
stringa=stringa+"_"
i=0
while ((eval("typeof("+stringa+i+")!='undefined'")) || (i==0)) {

// if there are no options, I empty the first option of the "son" combo
// otherwise I put "-select-" in it

if ((i==0) && eval("typeof("+stringa+"0)=='undefined'"))
if (eval("typeof("+stringa+"1)=='undefined'"))
eval("son.options[0]=new Option(displaywhenempty,valuewhenempty)")
else
eval("son.options[0]=new Option(displaywhennotempty,valuewhennotempty)")
else
eval("son.options["+i+"]=new Option("+stringa+i+".text,"+stringa+i+".value)")
i=i+1
}
//son.focus()
i=1
combostatus=''
cstatus=stringa.split("_")
while (cstatus[i]!=null) {
combostatus=combostatus+cstatus[i]
i=i+1
}
return combostatus;
}
}

function redirect(x){
for (m=temp.options.length-1;m>0;m--)
temp.options[m]=null
for (i=0;i<group[x].length;i++){
temp.options[i]=new Option(group[x][i].text,group[x][i].value)
}
temp.options[0].selected=true
}

function go(){
location=temp.options[temp.selectedIndex].value
}

//-->
</script>

<form>
<select name="combo0" id="combo_0" onChange="change(this);" style="width:160px;">
<option value="value0">Indique Presión</option>
<option value="value1">B4 60 psi</option>
<option value="value2">B5 75 psi</option>
<option value="value3">B6 90 psi</option>
<option value="value4">B8 120 psi</option>
<option value="value5">B10 150 psi</option>
<option value="value6">B12.5 185 psi</option>
<option value="value7">B16 235 psi</option>
<option value="value8">B20 290 psi</option>


</select>
<BR><BR>
<select name="combo1" id="combo_1" onChange="change(this)" style="width:160px;">
<option value="value1"> </option>
</select>
<BR><BR>
<select name="combo2" id="combo_2" onChange="change(this);" style="width:160px;">
<option value="value1"> </option>
</select>
<BR><BR>
<select name="combo3" id="combo_3" onChange="change(this);" style="width:160px;">
<option value="value1"> </option>

</select>

</form>