Link to home
Start Free TrialLog in
Avatar of DavidInLove
DavidInLoveFlag for France

asked on

javascript get selected index from select using IE9

Hi,


This javascript code was OK with previous version of IE and still is with
Fire Fox but unfortunately not with IE9


Could some one help myself, Please?????


 var cost = (indexsite .options[listecost.selectedIndex].value);


It is about a HTML select to get the selected index:


 var indexsite = document.getElementById('collabro');
   var val = (indexsite .options[collabro.selectedIndex].value).split("#");
   matricule=val[2].replace("(","");
       matricule_RO=matricule.replace(")","");
   nom_RO = val[0]+' '+val[1];  
   indexsite = document.getElementById('listecost');
   var cost = (indexsite .options[listecost.selectedIndex].value);


Thanks a lot??????????????
SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DavidInLove

ASKER

I have tried both solutions but there is still the bugg.
It seems this code is OK just for FireFox not for IE
Let me check ill get back 2u
OK Thanks a lot
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I have tried this already but unfortunately it was not succed
var cost = indexsite.options[indexsite.selectedIndex].text
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try separating the .split() command, just a hunch.
This I've found in
http://www.w3schools.com/jsref/prop_select_selectedindex.asp

function displayResult()
 {
 var x=document.getElementById("mySelect").selectedIndex;
 var y=document.getElementById("mySelect").options;
 alert("Index: " + y[x].index + " is " + y[x].text);
 }
 </script>
 </head>
 <body>
 
<form>
 Select your favorite fruit:
 <select id="mySelect">
   <option>Apple</option>
   <option>Orange</option>
   <option>Pineapple</option>
   <option>Banana</option>
 </select>
 </form>