473,387 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Show the selected item in a long list after a submit

I have a Select list with a size of 10, but with more than 10 options
in the list. After I select an item and submit the form I would like
the list be scrolled down to show the previously selected item still
selected and displayed at the top of the Select box.

Thanks.
Jun 27 '08 #1
3 1318
br*********@pwgsc.gc.ca writes:
I have a Select list with a size of 10, but with more than 10 options
in the list. After I select an item and submit the form I would like
the list be scrolled down to show the previously selected item still
selected and displayed at the top of the Select box.
If you submit the form, a new page is loaded.
If the new page contains the same form, you should make the server
set the selected element on the select control before sending it.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jun 27 '08 #2
br*********@pwgsc.gc.ca wrote:
I have a Select list with a size of 10, but with more than 10 options
in the list. After I select an item and submit the form I would like
the list be scrolled down to show the previously selected item still
selected
You can try

<head>
...
<script type="text/javascript">
function scrollSelect()
{
var s = document.forms[...].elements[...];
s.selectedIndex = s.selectedIndex;
}
</script>
</head>

<body onload="scrollSelect()">
...
</body>

but there is no guarantee that it will work as supposed.
and displayed at the top of the Select box.
If you think about this further, you will recognize it cannot be done for
every item.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Jun 27 '08 #3
If you submit the form, a new page is loaded.
If the new page contains the same form, you should make the server
set the selected element on the select control before sending it.
Yes, that is what I do now, but if the selected item is not in the
first 10 it will not be shown. I have to scroll down and when I get
to it I will see it selected. I want the scroll to happen
automatically so that the selected item is seen in the size 10 Select.
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Matthew Louden | last post by:
if the user select the EmployeeID in drop down list, and then click the submit button, and it will look up database and show the Employee Name in the text box, this is easy. But my case is:...
2
by: Paul | last post by:
Hi, I hope somebody can help me with the following. (I have tried searching for a solution on the newsgroups but nothing is quite what I need. Feel free to point me in the direction of anything...
10
by: dhnriverside | last post by:
Hi guys Still having a problem with this dropdownlist. Basically, I've got 4. The first 2 work fine, then my code crashes on the 3rd. ddlEndTimeHour.Items.FindByValue(endTime).Selected =...
3
by: RJN | last post by:
Hi The texts in the dropdown are too long and the width is not sufficient to show the entire text. Increasing the width is not an option. Is there a way to show the selected item text as a...
6
by: | last post by:
Do you have to use AutoPostBack to read the selected value in a dropdown list? I have an asp.net dropdown on a form. I'm filling it from a table when the page loads and want to read the value the...
4
by: devine | last post by:
Hi All, I am VERY new to Javascript. I have been provided with some code, which will enable me to hide/show a text area and change a submit button dependant on a check box. <!DOCTYPE html...
4
by: coldfusionstudent | last post by:
i wish to show/appear and dissappear text box based on a the drop down item selected. what do i have to add? thanks under Comm_DEV drop down selection.
3
by: Ming | last post by:
I have two list box (A and B), and I have two buttons to move list items (options) from this box to the other.I have a submit button to submit the form. I know how to move items from A to B by...
1
by: yasminussain | last post by:
Hi to all, I have written one jsp file. In that file, I have one drop down which contains list of request name (like student name) based on the selected value within drop down I will display the...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.