By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,480 Members | 1,229 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,480 IT Pros & Developers. It's quick & easy.

Setting the selectedValue in an option element.

P: n/a
I thought this would be a problem easily fixed in a simple Google
search, but I'm having a hard time finding a solution. I simply need a
way to set the value of an option element from an option value provided
in an AJAX response. I'm doing just fine with text boxes and div
elements, but the option value eludes me. I've tried the following:

document.editForm.co_status.selected =

document.editForm.co_status.selectedValue =

document.forms['editForm'].elements['co_status'].selectedIndex =

document.editForm.co_status.options.selected =

document.editForm.co_status.options.selectedValue =

....and a few others.

(The last two break the function.)

I'd sure appreciate some pointers or resource!


Dec 18 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a

The OPTIONS object, are children of the parent SELECT, and is not 1
element, is a collection, so, you address the 1st one by
document.editForm.co_status.options[0] and you can R/W its .text
(text shown) property and .value (or value attribute) property.

Dec 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.