Home > Backend Development > PHP Tutorial > How to use php array to fill drop-down list box, php array drop-down list box_PHP tutorial

How to use php array to fill drop-down list box, php array drop-down list box_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 09:58:50
Original
951 people have browsed it

php method of using array to fill drop-down list box, php array drop-down list box

This article describes the method of php using array to fill drop-down list box. Share it with everyone for your reference. The specific implementation method is as follows:

<&#63;php
$data = array(
  (object)array("titulo"=>"Ford", "valor"=>"opcion1"),
  (object)array("titulo"=>"Peugeot", "valor"=>"opcion2"),
  (object)array("titulo"=>"Chevrolet", "valor"=>"opcion3"),
  (object)array("titulo"=>"Volskwagen", "valor"=>"opcion4"),
);
&#63;>
<html>
<header>
<script>
function onCambioDeOpcion(combobox) {
  alert("Seleccionaste: " + combobox[combobox.selectedIndex].text +
   " \nSu valor es: " + combobox.value);
}
</script>
</header>
<body>
<select class="select_autor" name="autor" 
onchange="onCambioDeOpcion(this)" >
<option selected="selected">Seleccione fabricante</option>
<&#63;php
for($i=0; $i<count($data); $i++)
{
&#63;>
  <option value="<&#63;php echo $data[$i]->valor &#63;>">
  <&#63;php echo $data[$i]->titulo &#63;></option>
<&#63;php
}
&#63;>
</select>
</body>
</html>
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/976692.htmlTechArticleHow to use array to fill drop-down list box in php, php array drop-down list box This article describes how to use php array to fill drop-down list box List box method. Share it with everyone for your reference. Specific actual...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template