Hola,
ps veo que
ni has sacado 
siquiera la unidad
de la consuta, bueno modifica
esto aver si asi ya funciona bien ... 
 Código PHP:
    while ($row1=mysql_fetch_array($resump))
{  
print "<option value='".$row1["codigo"]."' alt='". $row1["unidad"] ."'> 
        ".$row1["nombre"]."</option>";
} 
    
  js 
 Código HTML:
 var code = document.getElementById('names_list').options[document.getElementById('names_list').selectedIndex].value;
var name = document.getElementById('names_list').options[document.getElementById('names_list').selectedIndex].text;
var unid = document.getElementById('names_list').options[document.getElementById('names_list').selectedIndex].getAttribute("alt");
                document.getElementById('code').value=code;
                document.getElementById('name').value=name;
                document.getElementById('unid').value=unid;
 echate un curso de 
php www.illasaron.com/
con este yo aprendi  n_n
y de paso uno 
Javascript no 
Java 
bueno te cuidas
Saudos
:]