Javascript dropdown selected value doesn't work in IE -


i have javascript switch case statement redirect page or show/hide text box depends on user selects dropdown box value. works fine in firefox not ie. error message below: script5007: unable value of property 'value': object null or undefined _index.htm, line 67 character 7

switch (document.form.description.options[description.selectedindex].value) - ie having hard time form.desciprition.

<script language="javascript">  function fundsource()    {        var val;          (i=0; i< document.form.description.length; i++)        {              switch (document.form.description.options[description.selectedindex].value)              {                 case "select":                     document.form.scholarship.style.visibility='hidden';                     document.form.description_other.style.visibility='hidden';                     break;                 case "wall of friends":                     location.href= url                     break;                 case "scholarship":                     document.form.scholarship.style.visibility='visible';                       break;                 case "other":                     document.form.description_other.style.visibility='visible';                     document.getelementbyid("descriptionspan").style.visibility="visible";                     break;               }        }    } </script> 

html code below:

<tr>                     <td align="right">description of fund donation <br /></td>                     <td>          <select name="description" id="description" onchange="fundsource()">                         <option>select</option>                         <option>scholarship</option>                         <option>rainbow of life</option>                         <option>wall of friends</option>                         <option>general</option>                         <option>other</option>                      </select>                     <select name="scholarship" id="scholarship" style="visibility:hidden;">                         <option>alumni scholarship</option>                         <option>other</option>                     </select>                     </td>                   </tr>                    <tr>                     <td align="right" valign="top"><div id="descriptionspan" alt="description" style="visibility:hidden;">other, please specify:</div></td>                     <td><input type="text" name="description_other" size="50" alt="fund other" style="visibility:hidden;" /></td>                   </tr> 

i changed document.form.description.options[description.selectedindex].value document.form.description.options[description.selectedindex].text, still doesn't work. please advise. tia.

if plan use

document.getelementbyid("description").value 

in switch case, must add "value" attribute option tags like

<option value="scholarship">scholarship</option> 

this code doesn't have in loop too, can do

function fundsource() {    var val = document.getelementbyid("description").value;         switch (val) {             case "select":                 document.form.scholarship.style.visibility='hidden';                 document.form.description_other.style.visibility='hidden';                 break;             case "wall of friends":                 location.href= url                 break;             case "scholarship":                 document.form.scholarship.style.visibility='visible';                 break;             case "other":                 document.form.description_other.style.visibility='visible';                 document.getelementbyid("descriptionspan").style.visibility="visible";                 break;         }  } 

hope helps.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -