[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2808
  • Last Modified:

JavaScript OnChange event IE 6 problem

Hi, all

I am facing a problem with a very easy script that i did for a site.
I have o drop down menu and a text area in a page.
I want to be able when i change the drop down menu to change the value of the text area

Below is the code that i use.

The code plays fine in Firefox but not to IE

<form name="myform" >

  <table width="433" border="0" cellspacing="0" cellpadding="0">
     <tr>
 <td><select name="place" class="forForms" id="place" onChange='valid(this.form)'>
      <option >City1</option>
        <option >City2</option>
        <option >City3</option>
      </select></td></tr>
    <tr>
      <td height="40" valign="top"><span class="forTexts">
        <textarea name="partners" cols="60" rows="7" class="forForms" id="partners"></textarea>
      </span></td>
      <td class="forTexts">&nbsp;</td>
    </tr>
  </table>


the JavaScript is

function valid(form){
var input="";

input=document.myform.place.value;

      switch (input) {
            case "City1" :
            document.myform.partners.value = "Comment1"      ;
            break;
            case "City2" :
            document.myform.partners.value = "Comment2"      ;
            break;
            case "City3" :
            document.myform.partners.value = "Comment2"      ;
            break;

      }
}


thanks
0
Panagiotis S
Asked:
Panagiotis S
1 Solution
 
william007Commented:
This will work in both IE and Firefox.
<script>
function valid(form){

var input="";

input=document.myform.place.options[document.myform.place.selectedIndex].text;

     switch (input) {
          case "City1" :
          document.myform.partners.value = "Comment1"     ;
          break;
          case "City2" :
          document.myform.partners.value = "Comment2"     ;
          break;
          case "City3" :
          document.myform.partners.value = "Comment2"     ;
          break;


     }
}
</script>
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now