Avatar for Username

ძიება მხარდაჭერაში

ნუ გაებმებით თაღლითების მახეში მხარდაჭერის საიტზე. აქ არასდროს მოგთხოვენ სატელეფონო ნომერზე დარეკვას, შეტყობინების გამოგზავნას ან პირადი მონაცემების გაზიარებას. გთხოვთ, გვაცნობოთ რამე საეჭვოს შემჩნევისას „დარღვევაზე მოხსენების“ მეშვეობით.

Learn More

Getting Error: DROPDOWN is not a function - Works in IE9

  • 1 პასუხი
  • 1 მომხმარებელი წააწყდა მსგავს სიძნელეს
  • 39 ნახვა
  • ბოლოს გამოეხმაურა cor-el

I'm trying to remove the default value selected in a drop-down box.

The call to the function is this: onchange="javascript:Remove_Default_Value(this);"

Here is the function:

function Remove_Default_Value(DROPDOWN) {
 var i = DROPDOWN.options.length - 1;  
 for ( i; i >= 0; i--)   
 {  
  DROPDOWN(i).defaultSelected = false;
 }  
} 

The error I'm getting is "DROPDOWN is not a function".

Any ideas is greatly appreciated.

I'm trying to remove the default value selected in a drop-down box. The call to the function is this: onchange="javascript:Remove_Default_Value(this);" Here is the function: <pre><nowiki>function Remove_Default_Value(DROPDOWN) { var i = DROPDOWN.options.length - 1; for ( i; i >= 0; i--) { DROPDOWN(i).defaultSelected = false; } } </nowiki></pre> The error I'm getting is "DROPDOWN is not a function". Any ideas is greatly appreciated.

ჩასწორების თარიღი: , ავტორი: cor-el

გადაწყვეტა შერჩეულია

It is not a function, but an array and you also need to use getElementsByTagName()

function Remove_Default_Value(DROPDOWN) {
 var i = DROPDOWN.getElementsByTagName("option").length - 1;  
 for ( i; i >= 0; i-- )   
 {  
  DROPDOWN.getElementsByTagName("option")[i].defaultSelected = false;
 }  
} 

A good place to ask advice about web development is at the MozillaZine "Web Development/Standards Evangelism" forum.

The helpers at that forum are more knowledgeable about web development issues.
You need to register at the MozillaZine forum site in order to post at that forum.

პასუხის ნახვა სრულად 👍 0

ყველა პასუხი (1)

შერჩეული გადაწყვეტა

It is not a function, but an array and you also need to use getElementsByTagName()

function Remove_Default_Value(DROPDOWN) {
 var i = DROPDOWN.getElementsByTagName("option").length - 1;  
 for ( i; i >= 0; i-- )   
 {  
  DROPDOWN.getElementsByTagName("option")[i].defaultSelected = false;
 }  
} 

A good place to ask advice about web development is at the MozillaZine "Web Development/Standards Evangelism" forum.

The helpers at that forum are more knowledgeable about web development issues.
You need to register at the MozillaZine forum site in order to post at that forum.