Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop down menu problems

Status
Not open for further replies.

frankcpl

Technical User
Mar 16, 2007
77
US
Could someone look at this and see what I am doing wrong, or is there and easier way to do this.

function degreeSelect() {
var selectedValue = document.getElementById("selDegree").value;
document.getElementsByClass("acadDegree_list").style = "display: none";
document.getElementsByClass("busDegree_list").style = "display: none";
document.getElementsByClass("carDegree_list").style = "display: none";
if(selectedValue == "Academic_Degree")
document.getElementsByClass("acadDegree_list").style = "display: block";
if(selectedValue == "Business_Degree")
document.getElementsByClass("busDegree_list").style = "display: block";
if(selectedValue == "Career_Certificate")
document.getElementsByClass("carDegree_list").style = "display: block";
}



<div class="div_hide_class"><label class="cf_label"
style="width: 150px;">What is
your Major?</label>
<select class="div_hide_class" id="selDegree" onchange="degreeSelect();" size="1" title=""
name="selDegree">
<option value="">Choose
Option</option>
<option value="Academic_Degree">Academic Degree</option>
<option value="Business_Degree">Business Degree</option>
<option value="Career_Certificate">Career Certificate</option>
</select>
<a class="tooltiplink" onclick="return false;"><img class="tooltipimg"
alt="" src="components/com_chronocontact/css/images/tooltip.png"
border="0" height="16" width="16"></a>
<div class="tooltipdiv">What
is your Major? :: You will be able to discuss this choice during
advisement .</div>
</div>
<div class="cfclear"> </div>
</div>
<div class="acadDegree_list" style="display: none;">
<div class="form_element cf_dropdown">
<label class="cf_label" style="width: 150px;">Academic Degrees</label>
<select class="cf_inputbox" id="select_54" size="1" title="" name="acadDegreeOpt" >
<option value="">Choose Option</option>
<option value="00205 Accountancy">00205 Accountancy</option>
<option value="00120 Animal Science">00120 Animal Science</option>
<option value="00405 Art">00405 Art</option>


</select>

</div>
<div class="cfclear"> </div>
</div>

<div class="busDegree_list" style="display: none;">
<div class="form_element cf_dropdown">
<label class="cf_label" style="width: 150px;">Business Degrees</label>
<select class="cf_inputbox" id="select_55" size="1" title="" name="busDegreeOpt">
<option value="">Choose Option</option>
<option value="06005 Accounting Technology">06005 Accounting Technology</option>
<option value="06022 Ag Bus & Mgmt Tech/Animal Husb">06022 Ag Bus & Mgmt Tech/Animal Husb</option>
<option value="06010 Agricultural Technology">06010 Agricultural Technology</option>


</select>

</div>
<div class="cfclear"> </div>
</div>

<div class="carDegree_list" style="display: none;">
<div class="form_element cf_dropdown">
<label class="cf_label" style="width: 150px;">Career Techinal</label>
<select class="cf_inputbox" id="select_56" size="1" title="" name="carDegreeOpt">
<option value="">Choose Option</option>
<option value="08014 Automotive Technology">08014 Automotive Technology</option>
<option value="06031 Civil Technology">06031 Civil Technology</option>
<option value="08005 Collision Repair Technology">08005 Collision Repair Technology</option>

</select>
 
Hi

[ul]
[li]The [tt]document[/tt] object has no getElementsByClass() method.[/li]
[li]if you want to use [tt]document.getElementsByClass[red]Name[/red]()[/tt], it returns an array, so it has no style attribute. Only the items contained by it have.[/li]
[/ul]


Feherke.
 
I am not understanding what you mean by that? can you please go into it a little more?
 
Hi

frankcpl said:
I am not understanding what you mean by that?
Let us try with some examples.

If "that" means the first point :
Code:
[blue]>>> typeof document.getElementsByClass[/blue]
[red]"undefined"[/red]
[blue]>>> typeof document.getElementsByClassName[/blue]
[red]"function"[/red]
If "that" means the second point :
Code:
[blue]>>> document.getElementsByClassName('col')[/blue]
[b][[/b] [blue]a[/blue][red].col[/red] [gray][i]/forummanagement.cfm[/i][/gray], [blue]div[/blue][red].col[/red], [blue]div[/blue][red].col[/red] [b]][/b]
[blue]>>> typeof document.getElementsByClassName('col').style[/blue]
[red]"undefined"[/red]
[blue]>>> typeof document.getElementsByClassName('col')[0].style[/blue]
[red]"object"[/red]
Note that the above examples were executed in this page's ( this Tek-Tips thread ) context.

If you have more questions, ask them. But please refer to the subject bore specifically than "that".

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top