aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes options not working in ie Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "options not working in ie" Watch "options not working in ie" New topic
Author

options not working in ie

Pat Peg
Ranch Hand

Joined: Feb 04, 2005
Posts: 194
Hi all,

I wrote a little script to determine what item had been selected in a list and it worked fine in firefox. When I tried it in ie it fails. Here is the script.
It is suppose to take the users input from one select list and activate some other select list depending on the option selected
function getSelected(){

var temp_selected = typeList.options[typeList.selectedIndex].text;
if(temp_selected == "FRUIT")
document.getElementById("fruitList").disabled=false;

I get an error about typeList being undefined.

Here is the code in the body...

<SELECT NAME="frmType" id="typeList" onChange="getSelected()">
<OPTION value="FRUIT">FRUIT
<OPTION value="VEGGIE">VEGGIE
<OPTION value="MEAT">MEAT
</SELECT>

while you are looking at it, i have another issue that I don't even know how to start to tackle. I would like to 'roll back' or set other drop down list as the first list is changed.

In other words, if I select fruit then the fruit menu activates and I can select any fruit but if I go back to the typeList and select VEGGIE, I want to reset the value in fruitlist to N/A and deactivate it.

While that would be nice to do, I will be happy if someone can point out the fix for ie to me and explain why. I don't work with ie normally

Thnaks
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Did you define the variable?

You should have something like



For your other thing, sounds like you just need to remove the selection from the select element

foo.options[foo.selectedIndex].selected=false;

Eric
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I should also mention. If you look in Firefox's jS console, I am sure it has a warning about needing to reference the object correctly.

Eric
Pat Peg
Ranch Hand

Joined: Feb 04, 2005
Posts: 194
Thanks, that looks like it did it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: options not working in ie