Ver Mensaje Individual
  #5 (permalink)  
Antiguo 16/11/2009, 07:24
crujikoki
 
Fecha de Ingreso: diciembre-2007
Ubicación: Barcelona
Mensajes: 289
Antigüedad: 16 años, 5 meses
Puntos: 8
Respuesta: Enviar datos desde un checkbox hacia un textarea

Hola,

Mira a ver si esto es lo que quieres:

Código:
<html>
<head>
<script lenguage="JavaScript">

var string1 = new String();
var string2 = new String();
	
var firstRowNums = new Array(0,0,0,0,0);
var secondRowNums = new Array(0,0,0,0,0);

function controlClick(obj)
{
	
	if(obj.checked)
	{
		if(obj.id<6)
			firstRowNums[obj.id-1] = obj.id;
		else
			secondRowNums[obj.id-6] = obj.id;
	}
	else
	{
		if(obj.id<6)
			firstRowNums[obj.id-1] = 0;
		else
			secondRowNums[obj.id-6] = 0;	
	}

	for(i=0; i<firstRowNums.length; i++)
	{
		if(firstRowNums[i] != 0)
			string1 = string1+firstRowNums[i]+"--";
	}
	
	for(i=0; i<secondRowNums.length; i++)
	{
		if(secondRowNums[i] != 0)
			string2 = string2+secondRowNums[i]+"--";
	}
	
	/*string1 = firstRowNums.join("--");
	string2 = secondRowNums.join("--");*/

	txtArea1.value = string1+"\n"+string2;
	string1="";
	string2="";
}


</script>
</head>
<body>
<input type="checkbox" id="1" name="chkbox1" onclick="controlClick(this)" vale="1">1</input>
<input type="checkbox" id="2" name="chkbox2" onclick="controlClick(this)" vale="2">2</input>
<input type="checkbox" id="3" name="chkbox3" onclick="controlClick(this)" vale="3">3</input>
<input type="checkbox" id="4" name="chkbox4" onclick="controlClick(this)" vale="4">4</input>
<input type="checkbox" id="5" name="chkbox5" onclick="controlClick(this)" vale="5">5</input><br>
<input type="checkbox" id="6" name="chkbox6" onclick="controlClick(this)" vale="6">6</input>
<input type="checkbox" id="7" name="chkbox7" onclick="controlClick(this)" vale="7">7</input>
<input type="checkbox" id="8" name="chkbox8" onclick="controlClick(this)" vale="8">8</input>
<input type="checkbox" id="9" name="chkbox9" onclick="controlClick(this)" vale="9">9</input>
<input type="checkbox" id="10" name="chkbox10" onclick="controlClick(this)" vale="10">10</input><br>

<textarea id="TA1" name="txtArea1" rows="5" cols="20"></textarea>
</body>
</html>
Si no, pues vuelve a postear y nos lo volvemos a mirar. La solución no es la mejor del mundo, pero la he hecho deprisa y corriendo y quizás se podría mejorar.

Espero que te sirva. Saludos.