Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Scrolling a Select Box

Posted on 1999-07-22
1
Medium Priority
?
177 Views
Last Modified: 2013-12-25
I have a select box that is dynamically filled with items via database.  One item will be returned with the "selected"
parameter on.  Is it possible to scroll the box so that the selected item will be shown, and if so, can I see some example code?
0
Comment
Question by:callapm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
sayasenh earned 150 total points
ID: 1864304
Hi,

A select box scrolls automatically in order to show the selected value :

VBScript :

MarcheSelect = Request("CodeMarche")
....
<BR><SELECT NAME = "CodeMarche" SIZE="1" onChange="this.form.submit()">

<OPTION VALUE = ""> Any End-use  </OPTION>      <%

Do While Not Rs1.EOF
      
   If Cstr(Rs1("CodeMarche")) = MarcheSelect Then            %><OPTION VALUE = "<% = Rs1("CodeMarche") %>"            SELECTED > <% =Rs1("Libelle")%> <%
   Else
      %><OPTION VALUE = "<% = Rs1("CodeMarche") %>"  > <% =Rs1("Libelle")%> <%

   End If
%></OPTION>

<% Rs1.MoveNext
Loop %>
</SELECT>

JavaScript :
The following  function might meet others sides of the problem :

1°) It stores in two hidden inputs (named "CodeMarche" and "CodeFonction") of the 3rd frame,  the selected values of two select boxes (named "CodeMarche" and "CodeFonction" as well), which are located respectively in the 1st and the 2nd frame, in the 1st form :

-> " = parent.frames[0].document.forms[0].CodeMarche. ..."
-> " = parent.frames[1].document.forms[0].CodeFonction. ..."

2°) The selected value of "CodeMarche" is 'unique' , but the selected value of "CodeFonction" is 'multiple' (hence, the 'for' is compulsory, because Netscape is quite fussy with the multiple attribute,
and if the result is to be "value1, value2, ...", you have to handle the comma, contrary to checkboxes).

function RecupParam(form){

form.CodeMarche.value = parent.frames[0].document.forms[0].CodeMarche.options[parent.frames[0].document.forms[0].CodeMarche.selectedIndex].value;

form.CodeFonction.value = "";
for (var i = 0; i < parent.frames[1].document.forms[0].CodeFonction.options.length; i++) {
   if (parent.frames[1].document.forms[0].CodeFonction.options[i].selected){
      if (form.CodeFonction.value != "" && form.CodeFonction.value != null){
            form.CodeFonction.value += ", "
      }
      form.CodeFonction.value += parent.frames[1].document.forms[0].CodeFonction.options[i].value;
   }
}
form.submit();
}

0

Featured Post

How To Reduce Deployment Times With Pre-Baked AMIs

Even if we can't include all the files in the base image, we can sometimes include some of the larger files that we would otherwise have to download, and we can also sometimes remove the most time-consuming steps. This can help a lot with reducing deployment times.

Question has a verified solution.

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

Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

722 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