i want to change the default value of dropdown list to 0 i.e selected index value shud become 0 when press the cancel button so that watever i selected previously is removed

here is the javsacript

function CloseDiv() {
            var control = document.getElementById("divReqStages");
            control.style.visibility = "hidden";
            
                  var control1 = document.getElementById('DDLReqStages').selectedIndex;
                    
      control1.value='0';
         
        }

here s asp.net code

<input type="button" name="btnCancel" style="font-size: xx-small" onclick="JavaScript:CloseDiv();" value="Cancel" />
function CloseDiv() {
            var control = document.getElementById("divReqStages");
            control.style.visibility = "hidden";
            
            document.getElementById('DDLReqStages').selectedIndex=0;
         
        }

The above will select the first OPTION in the SELECT list. IF you want NO option selected, then use -1 instead of zero

Thanks for ur advice but its still not working...the option which i selected and then cancelled is selected if i open the drop downlist

.the option which i selected and then cancelled is selected if i open the drop downlist

I don't understand what you are describing. IF you have a link to a test page or a copy of your code, it might make help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.