Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 3rd, 2004, 02:00 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to highlight selected data

Hi
I am working on ASP.I have one registration form on which i am using a dropdown list for multiple selection.In the update profile i want to hightlight the selected values in the dropdownlist.
I hope i am clear to explain my need.
Plz help me in this regard.

Regards
Lily

 
Old December 4th, 2004, 06:11 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Are you building the drop-down dynamically? If so, just add selected="selected" to the items you need to select, as in the following pseudo code:
Code:
<select>
<%
  For Each Record in your Drop Down Items
    If Record Matches User's selection
      Response.Write("<option value="Something" select="selected">Something</option>")
    Else
      Response.Write("<option value="Something">Something</option>")
    End If
  Next
%>
</select>
If you're not building the drop-down dynamically, you probably should change that so you *do* build it dynamically. ALternatively, you can use client side JavaScript to preselect the items...

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: The man with the red face by Laurent Garnier (Track 7 from the album: Unreasonable Behaviour) What's This?
 
Old December 4th, 2004, 07:04 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is my dropdown list values where there are multiple values selected.

<SELECT size=3 name=Updateme multiple>

                                  <OPTION value="None">None</OPTION>
                                  <OPTION value="Recruitment & Retention">Recruitment & Retention</OPTION>
                                  <OPTION value="People Management">People Management</OPTION>
                                  <OPTION value="Organisational Behaviour">Organisational Behaviour </OPTION>
                                  <OPTION value="Performance Management" >Performance Management</OPTION>
                                  <OPTION value="Strategic HRM" >Strategic HRM</OPTION>
                                  <OPTION value="Training & Development" >Training & Development</OPTION>
                                  <OPTION value="HR Practices">HR Practices</OPTION>
                                </SELECT>


from the database the value="<%=objrs("areas")%>"

How to display the multiple selected values in the drop down list.

 
Old December 4th, 2004, 07:06 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

And what does <%=objrs("areas")%> contain??


Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: The Tourist by Radiohead (Track 12 from the album: OK Computer) What's This?
 
Old December 4th, 2004, 08:26 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

objrs("areas") contains Recruitment & Retention,People Management,Organisational Behaviour .
Data is storing into the database with commas.

 
Old December 4th, 2004, 08:36 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

In that case, the pseudo code will look like this:
Code:
<select>
<%
  ' Split objrs("areas") into an array
  For Each Record in your Drop Down Items
    For Each Item in the Areas Array    
      If Record Matches Item From Areas Array
        Response.Write("<option value="Something" select="selected">Something</option>")
      Else
        Response.Write("<option value="Something">Something</option>")
      End If
    Next
  Next
%>
</select>
Does this make any sense?

Imar
--------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old December 4th, 2004, 08:38 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am very new in ASP programming, can u give the code and how to split the array.

 
Old December 4th, 2004, 08:43 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Dim myArray
myArray = Split("YourCommaSeparatedString", ",")

Also, look here:

http://www.google.com/search?hl=en&q...=Google+Search

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to select or highlight data grid row suji C# 0 November 12th, 2008 03:20 AM
To highlight multiple selected values in listbox lily611 General .NET 7 August 20th, 2007 12:59 AM
Another There is a problem with your selected data stevensrf1 ASP.NET 2.0 Basics 0 August 4th, 2007 02:02 PM
How to highlight selected dropdown values. sheetm J2EE 0 June 5th, 2007 05:04 AM
Selected Cell Highlight RollingWoodFarm Excel VBA 1 December 3rd, 2006 11:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.