943,169 Members | Top Members by Rank

Ad:
Sep 1st, 2010
0

Setting default value through javascript

Expand Post »
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

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. function CloseDiv() {
  2. var control = document.getElementById("divReqStages");
  3. control.style.visibility = "hidden";
  4.  
  5. var control1 = document.getElementById('DDLReqStages').selectedIndex;
  6.  
  7. control1.value='0';
  8.  
  9. }

here s asp.net code

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1.  
  2. <input type="button" name="btnCancel" style="font-size: xx-small" onclick="JavaScript:CloseDiv();" value="Cancel" />
Similar Threads
Reputation Points: 4
Solved Threads: 0
Light Poster
manavsm is offline Offline
27 posts
since Jun 2008
Sep 1st, 2010
0
Re: Setting default value through javascript
javascript Syntax (Toggle Plain Text)
  1. function CloseDiv() {
  2. var control = document.getElementById("divReqStages");
  3. control.style.visibility = "hidden";
  4.  
  5. document.getElementById('DDLReqStages').selectedIndex=0;
  6.  
  7. }
Reputation Points: 116
Solved Threads: 243
Veteran Poster
hielo is offline Offline
1,123 posts
since Dec 2007
Sep 1st, 2010
0
Re: Setting default value through javascript
The above will select the first OPTION in the SELECT list. IF you want NO option selected, then use -1 instead of zero
Reputation Points: 116
Solved Threads: 243
Veteran Poster
hielo is offline Offline
1,123 posts
since Dec 2007
Sep 2nd, 2010
0
Re: Setting default value through javascript
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
Reputation Points: 4
Solved Threads: 0
Light Poster
manavsm is offline Offline
27 posts
since Jun 2008
Sep 2nd, 2010
0
Re: Setting default value through javascript
Quote ...
.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.
Reputation Points: 116
Solved Threads: 243
Veteran Poster
hielo is offline Offline
1,123 posts
since Dec 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: <select> options selection on mouse over
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Could I download the html text from other website using AJAX?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC