我有一个嵌套的php数组。我已经填充了第一个选择。我希望第二个选择填充基于所选选项的php数组的值,这是我的php数组中的关键。我检查了其他帖子,它们似乎太复杂了,我无法理解和/或实施。一旦你看到它,我想你会理解的:
<?php
$books = array(
"លោកុប្បត្តិ"=> range(1,50),
"និក្ខមនំ"=> range(1,40),
"លេវីវិន័យ"=> range(1,27),
"ជនគណនា"=> range(1,36),
"ចោទិយកថា"=> range(1,34),
"យ៉ូស្វេ"=> range(1,24),
"ពូកចៅហ្វាយ"=> range(1,21),
"នាងរស់"=> range(1,4),
"សាំយូអែល ទី១"=> range(1,31),
"សាំយូអែល ទី២"=> range(1,24),
"ពង្សាវតារក្សត្រ ទី១"=> range(1,22),
"ពង្សាវតារក្សត្រ ទី២"=> range(1,25),
"របាក្សត្រ ទី១"=> range(1,29),
"របាក្សត្រ ទី២"=> range(1,36),
"អែសរ៉ា"=> range(1,10),
"នេហេមា"=> range(1,13),
"នាងអេសធើរ"=> range(1,10),
"យ៉ូប"=> range(1,42),
"ទំនុកដំកើង"=> range(1,150),
"សុភាសិត"=> range(1,31),
"សាស្ដា"=> range(1,12),
"បទចំរៀងសាឡូម៉ូន"=> range(1,8),
"អេសាយ"=> range(1,66),
"យេរេមា"=> range(1,52),
"បរិទេវ"=> range(1,5),
"អេសេគាល"=> range(1,48),
"ដានីយ៉ែល"=> range(1,12),
"ហូសេ"=> range(1,14),
"យ៉ូអែល"=> range(1,4),
"អេម៉ុស"=> range(1,9),
"អូបាឌា"=> range(1,1),
"យ៉ូណាស"=> range(1,4),
"មីកា"=> range(1,7),
"ណាហ៊ុម"=> range(1,3),
"ហាបាគុក"=> range(1,3),
"សេផានា"=> range(1,3),
"ហាកាយ"=> range(1,2),
"សាការី"=> range(1,14),
"ម៉ាឡាគី"=> range(1,3),
"ម៉ាថាយ"=> range(1,28),
"ម៉ាកុស"=> range(1,16),
"លូកា"=> range(1,24),
"យ៉ូហាន"=> range(1,21),
"កិច្ចការ"=> range(1,28),
"រ៉ូម"=> range(1,16),
"កូរិនថូស ទី១"=> range(1,16),
"កូរិនថូស ទី២"=> range(1,13),
"កាឡាទី"=> range(1,6),
"អេភេសូរ"=> range(1,6),
"ភីលីព"=> range(1,4),
"កូល៉ុស"=> range(1,4),
"ថែស្សាឡូនីច ទី១"=> range(1,5),
"ថែស្សាឡូនីច ទី២"=> range(1,3),
"ធីម៉ូថេ ទី១"=> range(1,6),
"ធីម៉ូថេ ទី២"=> range(1,4),
"ទីតុស"=> range(1,3),
"ភីលេម៉ូន"=> range(1,1),
"ហេព្រើរ"=> range(1,13),
"យ៉ាកុប"=> range(1,5),
"ពេត្រុស ទី១"=> range(1,5),
"ពេត្រុស ទី២"=> range(1,3),
"យ៉ូហាន ទី១"=> range(1,5),
"យ៉ូហាន ទី២"=> range(1,1),
"យ៉ូហាន ទី៣"=> range(1,1),
"យ៉ូដាស"=> range(1,1),
"វិវរណៈ"=> range(1,22)
);
?>
<script type="text/javascript">
function OnChange(dropdown)
{
//reload page after drop down selection
dropdown.options[dropdown.selectedIndex].value;
}
</script>
</head>
<body>
<div id="foo"></div>
<div id="links">
<form action="">
<select name="chapter">
<?php
foreach ($books as $key => $value) {
echo '<option value="' . $key . '">' . $key . '</option>';
}
?>
</select>
<br>
<select name="book">
<option value="">Select</option>
</select>
</form>
</div>
答案 0 :(得分:0)
有一个非常简单的脚本叫做“Chained选择jQuery插件”。这是因为你会使用javascript + jQuery。