[jQuery] Unable to refer to a select element
Hi,
I am trying to populate 3 selectboxes - one with years, months and
dates. The problem is that I keep getting a Javascript error in
Firebug. This is what I try:
I have this select:
<select name="yearFrom" style="visibility: hidden;"></select> // later
I set the select property to true
and I try to fill it like this:
function initDateFrom(){
var dateNow=new Date();
var yearFrom=$(":input[type=select][name=yearFrom]");
var monthFrom=$(":input[type=select][name=monthFrom]");
var dayFrom=$(":input[type=select][name=dayFrom]");
// populate yearFrom select
yearFrom.options[0] = new Option(" -- jaar -- ",0,true)
for(var i=1; i<=10; i++){
yearFrom.options[i] = new Option(dateNow.getFullYear()
+i,dateNow.getFullYear()+i)
}
... etc
I get an error "yearFrom.options is undefined"
When I initialy set the visibility property to true this makes no
difference, I still get the errormessage.
Is it impossible in jQuery to select an element as I do here (var
yearFrom=$(":input[type=select][name=yearFrom]");)?
Marc