Bueno gracias ante todo. Bien este codigo q voy a pegar funciona perfectamente.. lo que hace es abrir una ventana escribiendo una lista de los checkbox marcados. aqui va el codigo
Código:
<html>
<head>
<script language="JavaScript" type="text/javascript">
<!--
function funcion(){
winClose();
opTxt='';
cb=document.getElementsByTagName("input");
for (var n=0;n<cb.length;n++){
if(cb[n].getAttribute('name')&&cb[n].checked==true){
opTxt+='Componete: '+cb[n].getAttribute('name')+' valor: '+cb[n].getAttribute('value')+'<br>'
}
}
if (opTxt!=''){
openWindow();
}
}
var NewWin=null
function openWindow() {
NewWin=window.open("", "NewWinExample1", "resizable=yes,height=280,width=320,top=10,left=450")
NewWin.document.write(
"<head><TITLE>Componentes<\/TITLE><\/head>",
"<body style='font-family: Times New Roman; color: #000000; font-size: 12pt' BGCOLOR='#f3cf8d'>",
"<CENTER><br>"+opTxt,
"<\/CENTER><br>",
"<\/body>")
}
function winClose(){
if(NewWin && !NewWin.closed) NewWin.close()
}
//-->
</script>
</head>
<body onunload="javascript:winClose();" >
<form name=form1>
<table>
<tr>
<td>
alternador
</td>
<td>
<INPUT type=checkbox name=prop value="1" >
</td>
</tr>
<tr>
<td>
motor
</td>
<td>
<INPUT type=checkbox name=prop value="2" >
</td>
</tr>
<tr>
<td>
frenos
</td>
<td>
<INPUT type=checkbox name=prop value="3">
</td>
</tr>
<tr>
<td>
ruedas
</td>
<td>
<INPUT type=checkbox name=prop value="4">
</td>
</tr>
<tr>
<td>
<INPUT type=button value="enviar" onclick="funcion()">
</td>
</tr>
</table>
</form>
</body>
</html>
Bien .. lo que quiero es meterle un Id igual a los checkbox para usar en la funcion getElementsById en vez de getElementsByName, y q la funcion no llame a la ventana sino q devuelva un string con las frases, y q una otra funcion si quiere llame a ese string, lo quiero hacer para generalizar.. por si alguna vez necesitara usar la funcion en otro caso. A ver si me podeis ayudar..