Solved

cascading dropdown

Posted on 2010-09-23
6
964 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 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

20 Experts available now in Live!

Get 1:1 Help Now