R
RobG
I have a SELECT box with a big option list... with the value being the
primary key of a database query.
I want to be able to re-select the value in this select box based on a
new PK passed via Javascript, and I'm wondering if that's possible.
This doesn't appear to work:
function updateCRselect(fieldname, newvalue)
{
var element = document.getElementById(fieldname);
element.options[element.selectedIndex].value = newvalue;
}
My other guess is to somehow determine the option's own index value
based on the value of "newvalue" and then set it, but I don't know how
to do that.
Any suggestions?
Thanks!
Rob
primary key of a database query.
I want to be able to re-select the value in this select box based on a
new PK passed via Javascript, and I'm wondering if that's possible.
This doesn't appear to work:
function updateCRselect(fieldname, newvalue)
{
var element = document.getElementById(fieldname);
element.options[element.selectedIndex].value = newvalue;
}
My other guess is to somehow determine the option's own index value
based on the value of "newvalue" and then set it, but I don't know how
to do that.
Any suggestions?
Thanks!
Rob