0

Is there a possibility to generate a dropdown with checkboxes?

I have only seen javascript code that generates only a dropdown.

This is the script what I have written:

<!DOCTYPE html>
<html lang="en-US">
<head>
    <title>Test</title>

    <script type="text/javascript">
        function test() {
            var d = new Date();
            var currentYear = d.getFullYear();
            var currentMonth = d.getMonth();
            var yroptions = "<option value='0'>select</option>";

            for(var i = currentYear; i < currentYear + 5; i++)
            {
                yroptions += "<option value='"+i+"'>"+i+"</option>";
            }
            document.getElementById('ccexpy').innerHTML = yroptions;
        }
    </script>
</head>
<body onload="test()">

<form method="post" action="url to script">
    <label for="ccexpy">Year</label>
    <select id="ccexpy">

    </select>
</form>


</body>
</html>
2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.