简体   繁体   English

根据下拉框选择显示动态文本

[英]Displaying dynamic text based on drop down box selection

I am using Dreamweaver to create a site. 我正在使用Dreamweaver创建网站。 I have created my database within phpMyAdmin and have two tables set up that contain the data I wish to display on my site. 我已经在phpMyAdmin中创建了我的数据库,并设置了两个表,其中包含我希望在我的网站上显示的数据。 (it is a football team site and the page I am editing displays player profiles). (这是一个橄榄球队网站,我正在编辑的页面显示球员资料)。

I have set up a drop down box, which is connected to my players table in phpMyAdmin. 我已经设置了一个下拉框,该框连接到phpMyAdmin中的玩家表。 This I have set to display surname of the player. 我已设置为显示播放器的姓氏。 (I've set up the recordset to retrieve all data from my "players" table) Below that, I have another div which contains text that I want to display based on the selection on the drop down list. (我已经设置了记录集,以从“玩家”表中检索所有数据)在其下,我还有另一个div,其中包含要基于下拉列表中的选择显示的文本。 For example, Position, appearances, goals, assists, etc. 例如,位置,出场,目标,助攻等。

Position: Dynamic text to be displayed here Appearances: Dynamic text to be displayed here etc (This data would come from the "players_info" table - but the two tables are connected via the player_id field which is contained in both) 位置: 要在此处显示的 动态文本外观: 要在此处显示的动态文本等(此数据来自“ players_info”表-但是两个表通过两个都包含的player_id字段连接)

What I can't seem to do is work out how to get the text to update when the user would select a player from the drop down list. 我似乎无法做的是弄清楚当用户从下拉列表中选择一个播放器时如何更新文本。

Any help would be greatly appreciated. 任何帮助将不胜感激。

Thanks James 谢谢詹姆斯

You can do these using ajax function. 您可以使用ajax函数执行这些操作。 when you select a player name ,then javascript or jquery event will be called which include a php file. 当您选择播放器名称时,将调用包含php文件的javascript或jquery事件。 This php file must contain the sql which fetch your desired player information. 此php文件必须包含可获取所需播放器信息的sql。 when server give response, then display it your corresponding div 当服务器给出响应时,然后显示它对应的div

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

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