/    Sign up×
Community /Pin to ProfileBookmark

Select Tag issue!

I have a select tag issue!

[CODE]starttime=request.getParameter(“strtm”);
// where strtm is start time retrieving from URL query string
// strtm may contain any one of the values01:00,02:00,03:00…23:00

Start Time <%if(starttime!=null){%>
<select class=”blueTextField” name=”starttime”>
<% for(int i=0;i<24;i++){ %>
<option value=”<%=time[i]%>”><%=time[i]%></option>
<%}%>
</select>
[/CODE]

[COLOR=”DarkRed”][B]I want the starttime value to be selected when the page gets loaded. and the drop down should be as usual.
[/B]
[/COLOR]
Meaning, if the startime value is 08:00, this value should be selected (initially visible) in the select field.

When I give

[CODE]<option value=”<%=time[i]%>” selected=”<%=starttime%>”><%=starttime%></option>[/CODE]

the value is not getting selected.

ANY IDEAS OR SUGGESTIONS PLEASE???

RAKI.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@bathurst_guyJan 31.2007 — I think something more along the lines of this:&lt;option value="&lt;%=time[i]%&gt;" [B]&lt;% if(starttime == time[i]){ echo " selected";} &amp;&gt;[/B]&gt;&lt;%=starttime%&gt;&lt;/option&gt;Obviously I am a PHP guy, not ASP, So you will need to translate my PHP to ASP... but you can see what I am trying to do there.... Oh yes, this would be an ASP question more than a JavaScript.
Copy linkTweet thisAlerts:
@ramu_indianauthorJan 31.2007 — yup... i got it...

thanx anyways.....

[CODE]<%if(starttime!=null){%>
<td width="80%" align="left" valign="top">
<select name="starttime">
<% for(int i=0;i<24;i++){ %>
<%String ttime=time[i];
if(starttime.equals(ttime)) { %>
<option value="<%=time[i]%>" selected="yes"><%=time[i]%></option>
<%}else{%>
<option value="<%=time[i]%>"><%=time[i]%></option>
<%}%>
<%}%>[/CODE]
×

Success!

Help @ramu_indian spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...