简体   繁体   English

从选择字段中选择一个选项时,使用jquery输出javascript

[英]using jquery to output javascript when an option selected from select field

I have the following select field : 我有以下选择字段:

         echo '<select id="projects" name="project">';
            if(mysqli_num_rows($res)!=0)
            {   while(list($id,$title)=mysqli_fetch_row($res))

                {   
                echo '<option value='.$id.'>'.$title.'</option>';
                }
            }
            else
            {
                echo '<option>No projects alloted</option>';
            }
            echo '</select>';

What I want to do on selecting an option is use the selected id to generate another java script displaying a date range calendar which I already have. 我想在选择一个选项时要做的是使用选定的ID生成另一个显示我已经拥有的日期范围日历的Java脚本。 Then run a query referencing the selected project id and the start and end dates. 然后运行一个查询,引用所选的项目ID以及开始和结束日期。 I want to achieve this using jquery but don't know how to output another calendar javascript and the form that will store the selected values and at the same time also store the selected option. 我想使用jquery实现此目的,但不知道如何输出另一个日历javascript和将存储所选值并同时还存储所选选项的表单。 Can you please point me in the right direction. 你能给我指出正确的方向吗?

您可以通过$('#projects')。val()选择项目ID,并通过$('calenderId')。val()选择日历值。然后,您可以通过ajax Post发布这些值以生成所需的查询

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

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