0

Dear Sirs,

The below script is working fine on IE but notin Mozilla, could anyone help on this to be working on Mozilla as well?

<script type="text/javascript"> 
 window.onload=function() {  
  if (document.getElementById) { 
 document.getElementById("country").onchange=function() { switchme(this); }  
  } 
 } 
 function switchme(SNewSel) { 
 var ind = SNewSel.selectedIndex; 
 var txt = document.getElementById('country_code');
 switch (ind) { 
  case 1: txt.value = "+93"; break; 
  case 2: txt.value = "+358"; break; 
  case 3: txt.value = "+355"; break; 

 default: 
 txt.value=''; 
 break; 
 } 
} 
</script> 

<form action="output.php" method="post" name="myform" id="myform">
<select name="country">
<option value="Choose One" selected="selected" >Choose One</option>
<option value="AFG">Afghanistan</option>
<option value="ALA">Aland Islands</option>
<option value="ALB">Albania</option>
</select>

thanks in advance,
Cole

2
Contributors
4
Replies
9
Views
6 Years
Discussion Span
Last Post by vibhaJ
0

I forgot to put the text field where the result is pasted:

<input id="country_code" name="country_code" size="4" maxlength="6" class="boxinput">
0

Try this.

<script type="text/javascript"> 
 window.onload=function() {  
  if (document.getElementById("country")) { 
 document.getElementById("country").onchange=function() { switchme(this); }  
  } 
 } 
 function switchme(SNewSel) { 
 var ind = SNewSel.selectedIndex; 
 var txt = document.getElementById('country_code');
 switch (ind) { 
  case 1: txt.value = "+93"; break; 
  case 2: txt.value = "+358"; break; 
  case 3: txt.value = "+355"; break; 

 default: 
 txt.value=''; 
 break; 
 } 
} 
</script> 

<form action="output.php" method="post" name="myform" id="myform">
<input id="country_code" name="country_code" size="4" maxlength="6" class="boxinput">
<select name="country" id="country">
<option value="Choose One" selected="selected" >Choose One</option>
<option value="AFG">Afghanistan</option>
<option value="ALA">Aland Islands</option>
<option value="ALB">Albania</option>
</select>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.