duanhai7274 2014-01-11 19:04
浏览 53
已采纳

第二个下拉选项与第一个下拉选择中的选择相关

I want to create a signup form, that its values will be stored in a database (mysql). Because i want the data to be in the correct format (New York instead of NY when asking for City) i am thinking in limiting the options using a drop down list. For example, when a user selects as a Country: UK, the second selection to narrow down to the cities inside UK and remove the rest cities of the world.

Can i do this with only PHP/HTML/MYSQL knowledge? Or do i need to know Javascript/Jquery and more?

Thanks in advance.

  • 写回答

4条回答 默认 最新

  • dongzhi9906 2014-01-11 23:04
    关注

    The best approach is to use jQuery (javascript) to manage the interaction with the server (this process is known as AJAX).

    First, jQuery is just a javascript library that makes it TONS easier to use javascript. Here is an interesting article about why jQuery is absolutely necessary. However, the two main reasons to use jQuery are: (1) cross-browser is done for you, and (2) waaaaaay less typing. Here are some great FREE resources for learning jQuery:

    theNewBoston.com
    phpAcademy.org

    Next, when using jQuery, you must first load the jQuery library. After that, you can type jQuery commands instead of javascript and much magic happens much easier. Load the library like this, in your head tags:

    <head>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    </head>
    

    Finally, look here for populating Select #2 based on results from Select #1:

    Populate Select2 based on Select1, from MySQL DB

    Populate dropdown 2 based on selection in dropdown 1

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化