Active Server Pages

Moderators: None (Apply to moderate this forum)
Number of threads: 1763
Number of posts: 4498

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Problem with DropDown and ASP Posted by Peace2u on 18 Jun 2006 at 1:00 AM
Hi everybody,

I am getting infos from a database to get a drop down list filled. When I submit the form I want to automatically select the selected item but it doesn't select. Heres my code where it doesn't work.

<SELECT onChange="javascript:document.SearchState.submit();" name="ddlSearchCountry">
<% Do While not rsCountries.EOF %>
<OPTION value="<% = rsCountries("CountryID") %>" <% if Request.Form("ddlSearchCountry") = rsCountries("CountryID") then %> selected <% end if %>>
<% = rsCountries("Country") %>
</OPTION>
<% rsCountries.MoveNext
loop
rsCountries.close%>
</SELECT>
I've done this tones of time but this time it just won't work. The Request.Form works because i checked if it gets filled by putting it beside <% = rsCountries("Country") %>.

Thank you in advance,

Andy
Report
Re: Fixed this is how Posted by Peace2u on 18 Jun 2006 at 1:40 AM
Hi everybody,

My Values are numeric. what I did was to convert my Request.Form and recordset values both to Int and then it worked.

<SELECT onChange="javascript:document.SearchState.submit();" name="ddlSearchCountry">
<% Do While not rsCountries.EOF %>
<OPTION value="<% = rsCountries("CountryID") %>" <% if cint(DistributorCountryID) = cint(rsCountries("CountryID")) then%>selected<%end if%>><% = rsCountries("Country") %></OPTION>
<% rsCountries.MoveNext
loop
rsCountries.Close%>
</SELECT>

/Peace2u my friends



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.