Solved

Select listbox value automatically

Posted on 2012-04-06
1
342 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Bootstrap Form 16 37
Any Way to rotate banner ads from Commission Junction? 2 36
Bootstrap question 4 26
Html split(text) Part2 6 20
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

685 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