简体   繁体   English

通过选择另一个组合框上的值,在组合框上显示结果

[英]Display results on combobox by selecting a value on another combobox

I have a problem in my project. 我的项目有问题。 I have these categories: 我有以下类别:

Football
Basketball
Tennis

and these sub categories: 以及这些子类别:

super league A
super league B
euroleague
Serie A

I have the categories and sub categories in my phpMyAdmin DB. 我在phpMyAdmin数据库中有类别和子类别。 I have this code now, that I display these two, in two different comboboxes, via queries from DB: 我现在有了这段代码,可以通过数据库查询在两个不同的组合框中显示这两个代码:

<?php
$category = mysql_query("SELECT * FROM katigories ORDER BY id_katigoria");
echo "<select name='katigoria'>";
echo "<option selected='selected' value='0'> Επιλογή κατηγορίας! </option>";
while($values = mysql_fetch_assoc($category))
{
    echo "<option value='$values[id_katigoria]'>".$values['katigoria']."</option>";
}
echo "</select>";
?>

and

<?php
$category = mysql_query("SELECT * FROM upokatigories ORDER BY id_upokatigoria");
echo "<select name='upokatigoria'>";
echo "<option selected='selected' value='0'> Επιλογή υποκατηγορίας! </option>";
while($values = mysql_fetch_assoc($category))
{
    echo "<option value='$values[id_upokatigoria]'>".$values['katigoria']."</option>";
}
echo "</select>";
?>

so far so good. 到现在为止还挺好。 But now my problem is that I want to select from the first one Basketball, and I want to see ONLY the euroleague to the second combobox. 但是现在我的问题是,我想从第一个篮球中进行选择,而我只希望看到欧洲联赛中的第二个组合框。

I don't know much about JS or jQuery, but I believe between two of them is the answer I am looking for. 我对JS或jQuery知之甚少,但我相信其中两个是我想要的答案。 Am I right? 我对吗?

Please any ideas, to continue, or any suggestions, about what to read and where to look? 请关于阅读内容和外观的任何想法,以继续或提出任何建议?

PS I found something similar here, but it was for C# or/and python..so, I hope I am not repeating any other questions PS我在这里找到了类似的东西,但是它是针对C#或/和python..so的,我希望我不再重复任何其他问题

You need some jQuery that makes an ajax call to the server to bring back the new dropdown list. 您需要一些对服务器进行ajax调用的jQuery,以带回新的下拉列表。 See here: http://www.codingcereal.com/2009/09/autopopulate-select-dropdown-box-using-jquery/ 参见此处: http : //www.codingcereal.com/2009/09/autopopulate-select-dropdown-box-using-jquery/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM