K
kevinold
Hello everyone,
I'm using the prototype.js libaries and am trying to parse a select
element that has been filled in via an ajax call (returning html of
<options>). I'm trying to loop through all the elements and set the
selectedIndex of the element, but it doesn't seem to be working.
Here's the code snippet. Let me know if I need to post more code:
var the_model = 'thunderbird';
function setModel(the_model) {
alert("in set model");
var model = $('model'); //shortcut provided by prototype.js
alert(model);
var modelre = new RegExp(the_model);
// Look through the models and match 'thunderbird'
for (var i=model.options.length-1; i>=0; i--) {
var m = model.options.value;
alert(m);
if ( modelre.test(m) ) {
model.selectedIndex = i;
}
}
}
I'd like to do this the true DOM way. Any help is appreciated!
Thanks,
Kevin
I'm using the prototype.js libaries and am trying to parse a select
element that has been filled in via an ajax call (returning html of
<options>). I'm trying to loop through all the elements and set the
selectedIndex of the element, but it doesn't seem to be working.
Here's the code snippet. Let me know if I need to post more code:
var the_model = 'thunderbird';
function setModel(the_model) {
alert("in set model");
var model = $('model'); //shortcut provided by prototype.js
alert(model);
var modelre = new RegExp(the_model);
// Look through the models and match 'thunderbird'
for (var i=model.options.length-1; i>=0; i--) {
var m = model.options.value;
alert(m);
if ( modelre.test(m) ) {
model.selectedIndex = i;
}
}
}
I'd like to do this the true DOM way. Any help is appreciated!
Thanks,
Kevin