Solved

Select listbox value automatically

Posted on 2012-04-06
1
334 Views
Last Modified: 2012-04-06
Hi,
  I created a multiselect list, and when the result is 1 I want to select the value automatically in the select box. I am getting below error

Message: Unable to set value of the property 'selected': object is null or undefined

but I see the listbox contains a value.


please let me know how can I do it.

Thank you
code.txt
0
Comment
Question by:Sthokala
1 Comment
 
LVL 23

Accepted Solution

by:
basicinstinct earned 500 total points
ID: 37817552
well like arrays the options nodelist is "base zero".
 so if length is 1 the first index is 0

if(myoptions.length==1){
    variantSelect.options[0].selected="selected";
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now