![]() Within the script tags, write a simple for loop by adding the following bold code: For this select tag, we’ll be generating the option elements using JavaScript.īefore we get further into this, we should take a look at what exactly loops are and how a for loop works.Īround line 66, add script tags as shown in bold: Notice that it contains option tags which we’ve already assigned values (years) to.Īround line 59, notice that the select tag with an ID of to-year is empty. Around line 36, locate the select tag with an ID of from-year.Return to index.html in your code editor.Leave the page open in Chrome so we can come back to it later.We want to set it so that after choosing a From value, the To value only shows years equal to or later than the chosen From value. Notice the range goes from Before 2000 to 2017. The only thing we’re going to focus on are the From/To menus.Ĭlick the menu next to From. This is a mockup of a form (which doesn’t actually function). Open index.html from the Volunteer-Form folder. ![]() You may want to open that folder in your code editor if it allows you to (like Visual Studio Code does). For this exercise we’ll be working with the Volunteer-Form folder located in Desktop > Class Files > yourname-JavaScript jQuery Class.Open your code editor if it isn’t already open. ![]() In this exercise, we’ll look at one way to do this by using a for loop. ![]() One of the things that programming is really good for is repeating the same (or similar) actions very quickly. Topics covered in this JavaScript & jQuery tutorial:Ĭreating a for loop, Using the for loop to set menus, Clearing the contents of a menu Exercise Preview During the course, you will get access to the accompanying class files, live instructor demonstrations, and hands-on instruction. Note: These materials are provided to give prospective students a sense of how we structure our class exercises and supplementary materials. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |