Hi there, I'm working on a script that let's you pick dates and times
and it will string it together, but I'm having trouble matching my
elements.

My form elements all have class of date_bits and they're a mix of
selects for month/day/a.m./p.m. and input boxes for time:

<p class="q"><label for="start_month">start</label>
<select name="start_month" class="date_bits">
<option value="01">January</option>
<option value="10" selected="selected">October</option>
</select>

at <input type="text" name="timenumber" class="date_bits" value="8">

<select name="timeend" class="date_bits">
<option value="a.m.">a.m.</option>
<option value="p.m.">p.m.</option>
</select>


My jquery is close, but I'm not sure how to properly test my if
statement. .is("input") works as expected, but how do I test for
select option:selected?

$(".date_bits").change(function () {
        var date_info = '';
                $(".date_bits").each(function () {
                        if ($(this).is("input")) {
                                date_info += " at " + $(this).val() + " ";
                        } else if ($(this).is("select")) {
                                date_info += $(this).val() + " ";
                        }
                });
        $("#alert_text").html(date_info);
        })
.trigger('change');


Please see this graphic for a visual example of what I'm trying to do
and what's wrong:
http://www.swfwmd.state.fl.us/testing/snip.jpg

Thanks for the help!
-dave

Reply via email to