JavaScript - Problema con JavaScript + PHP!

 
Vista:

Problema con JavaScript + PHP!

Publicado por Platha (1 intervención) el 05/03/2008 13:21:12
Bueno, tengo un problema a la hora de intentar pasar los elementos de una lista a otra lista mediante JavaScript combinado con PHP. Cuando pulso el boton para traspasar el elemento, me sale un "length es nulo" etc.

El codigo del PHP es:

<div id="3" style="border: 1px solid silver; margin: 10px; padding:20px; width: 900px">
<h3 align="left">ASSIGNATURES</h3>
<table width=80% align="center"><tr><td align="right" rowspan="2">
<?php
$sel="SELECT Nom FROM Assignatura";
$exec=mysql_query($sel);
//multiple size=" . mysql_affected_rows()
echo("<select name='asig' multiple id='a' size=10 style='width: 150px'>");
$res=mysql_fetch_row($exec);
while($res){
echo("<option value='" . $res[0] . "'>" . $res[0] . "</option>");
$res=mysql_fetch_row($exec);
}
echo("</select>");
?>
</td><td align="center">

<button type="button" name="Der" id="der" value="Der" onClick="move('right')" style="width:100px"><img src="gr_r_arr.gif"></button>
</td>
<td align="left" rowspan="2">
<select name='asigok' multiple align=center id="b" size=10 style="width: 150px">
</select>
</td>
</tr>
<tr>
<td align="center">
<button type="button" name="Izq" id="izq" value="Izq" onClick="move('left')" style="width:100px"><img src="gr_l_arr.gif"></button>
</td>
</tr>
</table>
</div>


Y El codigo Javascript:


if (side == "right")
{
attribute1 = document.prof.asig;
attribute2 = document.prof.asigok;
}
else
{
attribute1 = document.prof.asigok;
attribute2 = document.prof.asig;
}
//fill an array with old values

for (var i = 0; i < attribute2.length; i++)
{
y=current1++
temp1[y] = attribute2.options[i].value;
tempa[y] = attribute2.options[i].text;
}

//assign new values to arrays

for (var i = 0; i < attribute1.length; i++)
{
if ( attribute1.options[i].selected )
{
y=current1++
temp1[y] = attribute1.options[i].value;
tempa[y] = attribute1.options[i].text;
}
else
{
y=current2++
temp2[y] = attribute1.options[i].value;
tempb[y] = attribute1.options[i].text;
}
}

Gracias por las sugerencias!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder