0

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
i want it in javascipt only...i have done it in c#...since there s no forum for javascript i posted here only

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 the asp code....when i click here the drop down shud be reset

<input type="button" name="btnCancel" style="font-size: xx-small" onclick="JavaScript:CloseDiv();"  value="Cancel" />
4
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by dnanetwork
0
<select id="DDLReqStages">
	<option>Option 1</option>
	<option>Option 2</option>
	<option>Option 3</option>
	<option>etc.</option>
</select>
<input type="button" name="btnCancel" style="font-size: xx-small" onclick="JavaScript:CloseDiv();"  value="Cancel" />
<script type="text/javascript">
   function CloseDiv() {
           // var control = document.getElementById("divReqStages");
           // control.style.visibility = "hidden";
           document.getElementById('DDLReqStages').selectedIndex = 0; // Reset
        }
</script>
0

<select id="DDLReqStages">
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
<option>etc.</option>
</select>
<input type="button" name="btnCancel" style="font-size: xx-small" onclick="JavaScript:CloseDiv();" value="Cancel" />
<script type="text/javascript">
function CloseDiv() {
// var control = document.getElementById("divReqStages");
// control.style.visibility = "hidden";
var ddlControl = document.getElementById('DDLReqStages');
ddlControl.value=0;//set the value of the item to be selected.
}
</script>

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.