HTML form dropdown menu specify number range

You don't need Javascript, you can use a PHP for loop:

<select name="hour">
    <?php for ($i = 1; $i <= 24; $i++) : ?>
        <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
    <?php endfor; ?>
</select>

If you only wish to use Javascript, you could do something like:

for(var i=1; i<=24; i++){
    var select = document.getElementById("hours");
    var option = document.createElement("OPTION");
    select.options.add(option);
    option.text = i;
    option.value = i;
}

Here is a jsFiddle example: jsFiddle