简体   繁体   中英

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. Then run a query referencing the selected project id and the start and end dates. 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. Can you please point me in the right direction.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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