ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old August 18th, 2003, 10:07 AM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 54 sec
Reputation Power: 6
Send a message via AIM to unatratnag
select an option

Code:
SELECT NAME="time_zone" onchange="checkdisabled(this)">
<option selected>Choose Option</option>
<OPTION disabled=true>European
<OPTION disabled=true>
<OPTION disabled=true>GMT Greenwich Mean Time, as UTC
<OPTION>BST British Summer Time, as UTC+1 hour
<OPTION>IST Irish Summer Time, as UTC+1 hour
<OPTION disabled=true>WET Western Europe Time, as UTC
<OPTION>WEST Western Europe Summer Time, as UTC+1 hour
<OPTION>CET Central Europe Time, as UTC+1
<OPTION>CEST Central Europe Summer Time, as UTC+2
<OPTION>EET Eastern Europe Time, as UTC+2
<OPTION>EEST Eastern Europe Summer Time, as UTC+3
<OPTION>MSK Moscow Time, as UTC+3
<OPTION>MSD Moscow Summer Time, as UTC+4
<OPTION disabled=true>
<OPTION disabled=true>US and Canada
<OPTION disabled=true>
<OPTION>NST Newfoundland Standard Time, as UTC-3:30 hours
<OPTION>NDT Newfoundland Daylight Time, as UTC-2:30 hours
<OPTION>AST Atlantic Standard Time, as UTC-4 hours
<OPTION>ADT Atlantic Daylight Time, as UTC-3 hours
<OPTION>EST Eastern Standard Time, as UTC-5 hours
<OPTION>EDT Eastern Daylight Saving Time, as UTC-4 hours
<OPTION disabled=true>ET Eastern Time, either
and so on and so on you get the point


I'm autofilling this form. Typically what i've done is after the option, insert a little asp to check to see what the RS is and response.write "SELECTED" if the option value is = RS value.

Is there any all powerfull method i can use to have which option is selected without having to insert 30 million if statements in the option tag? I tried value="blah" and crossed my fingers and that didn't work of course, so anyone else know a way?

Reply With Quote
  #2  
Old August 18th, 2003, 10:10 AM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 54 sec
Reputation Power: 6
Send a message via AIM to unatratnag
<option <% if request.form("D1") <> "" then if RS("dateFlex") = "No" then response.write "SELECTED" end if end if %>>

this is what i've done in the past FYI

Reply With Quote
  #3  
Old August 18th, 2003, 10:20 AM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Are you dynamically building this <select>...</select>?

If so wouldn't that work?

----------------------------------------------------------
<SELECT NAME="time_zone" onchange="checkdisabled(this)">
<%
Dim IsSelected
IsSelected = NULL


While NOT RS.EOF

If Trim(Lcase(RS("dateFlex"))) = "no" Then

IsSelected = "SELECTED"

End If


Response.Write "<option " & IsSelected & ">" & RS("xxx") & "</option>"



RS.MoveNext
Wend

RS.Close
Set RS = nothing
%>
</SELECT>
----------------------------------------------------------

Note the RS("xxx") which represents the value you want to put between the <option>...</option>
I've also noticed that you didn't have a value attribute, is that what you want?


Hope this helps!
Sincerely

Vlince

Reply With Quote
  #4  
Old August 18th, 2003, 10:25 AM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 54 sec
Reputation Power: 6
Send a message via AIM to unatratnag
my code is just what it is, i'm not dynamically creating it. It's just a list of all the time zones so that never changes. I was wondering if there's an easier way to select a default value rather than do the if in each option.

Reply With Quote
  #5  
Old August 18th, 2003, 10:46 AM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Oh ok, what *I* would do is something like this:

Create a javascript function that builds your <select>...</select>

The javascript function would be called on the onload attribute of the <body> tag

something like:

<body onload="CreateCombobox()">

I would add, a parameter like this:

<body onload="CreateCombobox(<%=RS("xxx")%>)">

Remember that you can only have ONE value that is SELECTED inside a <select>...</select> so

Then the javascript function, which is defined inside the <head>...</head> section of your code would create the <select>...</select> looking to see if the parameter equals something.

If it does, then print the SELECTED


When I come to think of it, maybe your approach is better, I mean it's NOT that ugly and most importantly it works right?

I'd keep it like that! no?

Unless you want to build your <select>...</select> SERVER-SIDE? no?

The idea behind the SERVER-SIDE approach *avoids* making the "check" in each <option>...</option> EVEN if your values aren't dynamically driven(they are hard coded as you mention)

Hope I makes sense!
Sincerely

Vlince

Reply With Quote
  #6  
Old August 18th, 2003, 12:06 PM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 54 sec
Reputation Power: 6
Send a message via AIM to unatratnag
yea, i guess i'll just keep it server side, no it's not that ugly, but a pain in the arse to type in. Too many timezones in this world =(

you'd think someone smart would have built in a way to select a specific option in these.... lazy bums, didn't they know other people would be inventing server side languages soon?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > select an option


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway