Solved

cascading dropdown

Posted on 2010-09-23
6
966 Views
Last Modified: 2013-11-07
Hi experts,
I have a three cascading dropdowns for Coutry,State and City.
This works very well.
What I am trying to do is,
When 'Admin' is viewing a records of the user,those dropdowns shows values entered previously(That's done)
When normal user is viewing this form,I want to show data in readonly form,I tried to disable the dropdowns
 but it is not working.Those dropdowns should be disabled but should have value from database.

These dropdowns get data from web service.

Your help is really appreciated.
Thanks
0
Comment
Question by:johny_bravo1
  • 3
  • 2
6 Comments
 
LVL 5

Accepted Solution

by:
tvPrasad earned 500 total points
ID: 33743709
Make Dropdowns readonly for normal users. Here is how...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML lang="en">
<HEAD>
<TITLE>HTML</title>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<STYLE type="text/css">
<!--
.greyed {
color: #999999;
}
-->
</STYLE>
<SCRIPT language=JavaScript type=text/javascript>
<!--
function freezeList(whichList){
var chosen=whichList.options.selectedIndex;
whichList.onchange=function(){
whichList.options.selectedIndex=chosen;
}
whichList.className="greyed";
}
//-->
</SCRIPT>
</HEAD>
<BODY>

<FORM name="myForm">
<DIV>
<SELECT name="readList" readonly>
<OPTION>Red</OPTION>
<OPTION>Green</OPTION>
<OPTION>Blue</OPTION>
<OPTION>Yellow</OPTION>
</SELECT>
<INPUT type="button" value="Freeze The List" onclick="freezeList(this.form.readList)">
</DIV>
</FORM>

</BODY>
</HTML>
0
 
LVL 10

Expert Comment

by:Umar Topia
ID: 33743725
You can use dropdown variable object name
ddlTest.Enabled = false;
0
 
LVL 5

Expert Comment

by:tvPrasad
ID: 33743753
By definition, a dropdown is always READONLY.
By definition, a dropdown DISABLED is not sent via FORM SUBMIT.

If you are allowing multiple then you use below technique
----------------------------------------------------------------------------------------
<FORM name="myForm" method="post">
 <SELECT name="readList[]" multiple readonly onmouseover="freezeList(this.form.elements['readList[]'])">
 <OPTION value="Red">Red</OPTION>
 <OPTION value="Green" selected>Green</OPTION>
 <OPTION value="Blue">Blue</OPTION>
 <OPTION value="Yellow" selected>Yellow</OPTION>
 </SELECT>
 <INPUT type="submit" value="SUBMIT">
 <input type="button" value="freeze" />
 </FORM>

Hope this helps!!!
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 8

Author Comment

by:johny_bravo1
ID: 33743973
umartopia:
.Enabled = false don't work.It doesn't load any values then

tvPrasad:
I don't understand what you are trying to tell. sorry :)


I am posting some code.Please see.

<asp:DropDownList ID="ddlLocalCountry" runat="server" Width="130px" CssClass="inputtext">
            </asp:DropDownList>
            <cc1:CascadingDropDown ID="CDDddlLocalCountry" runat="server" Category="Country"
                TargetControlID="ddlLocalCountry" PromptText="[Select Country]" LoadingText="Loading countries..."
                ServicePath="~/HR/cascadingdataservice.asmx" ServiceMethod="GetDropDownCountries">
            </cc1:CascadingDropDown>



 <asp:DropDownList ID="ddlLocalState" onchange="ShowStateDiv()" runat="server" Width="100px" CssClass="inputtext">
                        </asp:DropDownList>
                        <cc1:CascadingDropDown ID="CDDddlLocalState" runat="server" Category="State" TargetControlID="ddlLocalState"
                            ParentControlID="ddlLocalCountry" PromptText="[Select State]" LoadingText="Loading states..."
                            ServicePath="~/HR/cascadingdataservice.asmx" ServiceMethod="GetDropDownStates">
                        </cc1:CascadingDropDown>


  <asp:DropDownList ID="ddlLocalCity" onchange="ShowOtherCity()" runat="server" Width="100px" CssClass="inputtext">
                        </asp:DropDownList>
 <cc1:CascadingDropDown ID="CDDddlLocalCity" runat="server" Category="City" TargetControlID="ddlLocalCity"
                    ParentControlID="ddlLocalState" PromptText="[Select City]" PromptValue="0" LoadingText="Loading cities..."
                    ServicePath="~/HR/cascadingdataservice.asmx" ServiceMethod="GetDropDownCities">
                </cc1:CascadingDropDown>

Open in new window

0
 
LVL 8

Author Comment

by:johny_bravo1
ID: 33754957
HI experts,pls give me some idea.I am lost
0
 
LVL 8

Author Closing Comment

by:johny_bravo1
ID: 33901510
not the exact solution but around there
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now