Home  >  Article  >  Backend Development  >  How to use an array to fill a drop-down list box in PHP_PHP Tutorial

How to use an array to fill a drop-down list box in PHP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 09:58:351049browse

How PHP uses an array to fill a drop-down list box

This example describes how PHP uses an array to fill a drop-down list box. Share it with everyone for your reference. The specific implementation method is as follows:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

$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"),

);

?>

<script></p> <p>function onCambioDeOpcion(combobox) {</p> <p>alert("Seleccionaste: " combobox[combobox.selectedIndex].text </p> <p>" nSu valor es: " combobox.value);</p> <p>}</p> <p></script>

1 2 3

4

6 7 8 9 10
11 12
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
<🎜>$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"), ); ?>
<script> function onCambioDeOpcion(combobox) { alert("Seleccionaste: " combobox[combobox.selectedIndex].text " nSu valor es: " combobox.value); } </script>
http://www.bkjia.com/PHPjc/977161.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/977161.htmlTechArticleHow to use an array to fill a drop-down list box in PHP. This example describes how to use an array to fill a drop-down list box in PHP. Share it with everyone for your reference. The specific implementation method is as follows: 1 2...
Statement:
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