douyu9159 2015-02-01 16:29
浏览 32

获取下拉列表的值并在php中使用它

I have designed a form in html5 with 4 dropdowns 1-Year 2-Department 3-Semester 4-Subject

I have used php to get the values of year,department,and semester.Now what i want is that based on the user selection for year,department,semester i want to get the subjects dynamically

I have written a query to get the subjects based on year,department,and semester

Query //for subject dropdown

select s.sub_name from 
subject s
inner join year y
on s.year_id=y.year_id
inner join dept d
on s.dept_id=d.dept_id
inner join sem sm
on s.sem_id=sm.sem_id
where y.year_id='' and  // get selected value from dropdown
d.dept_id='' and // get selected value from dropdown
sm.sem_id=''// get selected value from dropdown

Now how will i send those selected drop down values to the query in php dynamically.

  • 写回答

1条回答 默认 最新

  • dougou5844 2015-02-01 22:31
    关注

    I suppose your dropdowns use <select> with multiple <option> tags (see W3schools). Give your select a sensible name, and the value of the dropdown will be in $_POST['selectName'] or $_GET['selectName'] (depending on your form submission method).

    If you want to do this dynamically (i.e. when a user changes the dropdown), you'll have to come up with some JavaScript (AJAX) posting the selected value to your php-page (e.g. using jquery.post). You can then use the result of that post-call to fill in your dropdowns.

    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)