Darse de alta en la web | Recuperar password   
Inicio / Foros / HTML + XHTML / cargar array
5 respuestas recibidas | 1549 visitas | Categoría HTML + XHTML

cargar array

Avatar de cata
Nivel 1 Nivel 1 Nivel 1 Nivel 1 Nivel 1 Nivel 1 Nivel 1

(Nivel 1 - 4 posts)

#0 Offline cata Usuario 13 mar 07 (19:38)  
como podemos cargar un array en un select?

Re: cargar array

Avatar de oso96_2000
Nivel 3 Nivel 3 Nivel 3 Nivel 3 Nivel 3 Nivel 3 Nivel 3

(Nivel 3 - 235 posts)

#1 Offline oso96_2000 Usuario 13 mar 07 (20:02)  
o.o.. si, hola a ti tmb xD.. weno.. un array de que? ._.
En caso de que sea un array en php, seria algo como:

Código PHP


<select name="nombres">
<?php
$data
= array('alonso','juan','panfilo');
foreach (
$data as $indice => $nombre) echo '<option value="'.$indice.'">'.$nombre.'</a>';
?>
</select>


Y lo que sacará en pantalla es:

Código PHP


<select name="nombres">
<option value="0">alonso</option><option value="1">juan</option><option value="2">panfilo</option></select>



Esta hecho al tonteo, pero creo que funciona xD.. igual da la idea de como se hace

Sin Ideas
713869

Re: cargar array

Avatar de yosolito
Nivel 6 Nivel 6 Nivel 6 Nivel 6 Nivel 6 Nivel 6 Nivel 6

(Nivel 6 - 999 posts)

#2 Offline yosolito Usuario 13 mar 07 (20:04)  
con un foreach();

eval(gzinflate(base64_decode('s7fjSk3OyFdQt0myc3eMtNFPslNIzVEoLE1VyMlXyElN1FO35rKxBwA=')));

Re: cargar array

Avatar de cata
Nivel 1 Nivel 1 Nivel 1 Nivel 1 Nivel 1 Nivel 1 Nivel 1

(Nivel 1 - 4 posts)

#3 Offline cata Usuario 13 mar 07 (20:34)  
para cargar un array en un control select de javascript
gracias

Re: cargar array

Avatar de panino
Nivel 7 Nivel 7 Nivel 7 Nivel 7 Nivel 7 Nivel 7 Nivel 7

(Nivel 7 - 1185 posts)

#4 Offline panino Moderador 13 mar 07 (23:05)  
Podrías postear en el foro correcto, ¿no?

Código Javascript

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>test</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<select name="pepe" id="pepe">
</select>
<input type="button" name="Submit" value="llenar" onclick="arr=['rojo','anaranjado','amarillo','verde'];for(ii in arr)pepe.options[ii]=new Option(arr[ii],arr[ii])" />
</form>
</body>
</html>

www.disegnocentell.com.ar

-

Avatar de Onzalo
Nivel 2 Nivel 2 Nivel 2 Nivel 2 Nivel 2 Nivel 2 Nivel 2

(Nivel 2 - 69 posts)

#5 Offline Onzalo Usuario 15 mar 07 (05:01)  
- Perdon por ensuciar-
-_-

Borré un post mal puesto...

Responder mensaje

Para poder participar debes estar registrado e identificado. Si no estás registrado como usuario de PHP-Hispano, :: Registrar ::
Login / Password   

Web alojada en Zilos

php-hispano.net 2002 - 2008 | XHTML 1.0
Datos Legales | Webmaster