Overview
This prompt aims to enhance an HTML code snippet by adding a month selection feature and a reset button. Programmers and developers will benefit by improving user interface functionality and interactivity in their web applications.
Prompt Overview
Purpose: This code snippet allows users to filter rental data by year and month.
Audience: It is designed for developers working on a rental management application.
Distinctive Feature: The dropdown menus enable easy selection of year and month for filtering results.
Outcome: Users can apply filters and reload the page to view specific rental data based on their selections.
Quick Specs
- Media: Text
- Use case: Generation
- Industry: Development Tools & DevOps, Renewable Energy (Solar, Wind, Hydro)
- Techniques: Structured Output
- Models: Claude 3.5 Sonnet, Gemini 2.0 Flash, GPT-4o, Llama 3.1 70B
- Estimated time: 10-20 minutes
- Skill level: Intermediate
Variables to Fill
- [1] – 1
- [selectedYear] – Selectedyear
- [selectedMonth] – Selectedmonth
Example Variables Block
- [1]: 2023
- [selectedYear]: 2023
- [selectedMonth]: October
The Prompt
Please update the provided HTML code by adding a new select option for months.
Additionally, include a button that resets the filter and reloads the page accordingly.
The updated code should maintain the original styling and structure in the code snippet.
Make sure to:
– Initialize the new month dropdown properly.
– Ensure that the button triggers the filtering action.
Here’s the updated code snippet:
“`html
Year : @Model.ActiveYear
– All
– @year
Select Month
January
February
March
April
May
June
July
August
September
October
November
December
Apply Filter
“`
Additionally, please create the appropriate JavaScript function `applyFilter()` that:
– Grabs the selected month and year.
– Reloads the page according to the filters applied.
Here’s an example of how you can implement this function:
“`javascript
function applyFilter() {
var selectedYear = document.querySelector(‘.btn-group .dropdown-toggle’).innerText.split(‘: ‘)[1]; // Get the current selected year
var selectedMonth = document.getElementById(‘monthSelect’).value; // Get the selected month
window.location.href = `/Rent/Rentals?year=$[selectedYear]&month=$[selectedMonth]`; // Redirect to the filtered URL
}
“`
This will ensure that when users select a month and click the button, they will be redirected to the Rentals page with the specified filters activated.
Make sure to test the functionality after implementation to verify that the filters work as intended!
Screenshot Examples
How to Use This Prompt
- All
- @year
Tips for Best Results
- Keep Learning: Always stay updated with the latest programming languages and frameworks.
- Practice Regularly: Code daily to improve your skills and retain knowledge.
- Read Documentation: Familiarize yourself with official documentation for better understanding and usage of tools.
- Join Communities: Engage with programming communities for support, resources, and networking opportunities.
FAQ
- How do I add a month dropdown in HTML?
Include a select element with options for each month in your HTML code. - What does the applyFilter function do?
It retrieves selected year and month, then redirects to the Rentals page with filters. - How to reset the filter in the code?
Add a button that reloads the page without any filters applied. - Why is the month dropdown important?
It allows users to filter rentals by specific months, enhancing user experience.
Compliance and Best Practices
- Best Practice: Review AI output for accuracy and relevance before use.
- Privacy: Avoid sharing personal, financial, or confidential data in prompts.
- Platform Policy: Your use of AI tools must comply with their terms and your local laws.
Revision History
- Version 1.0 (February 2026): Initial release.


