Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Activiate a textbox on dropdown selection not working in IE8

Posted on 2013-11-15
2
454 Views
Last Modified: 2013-11-15
Hi,

I need to get a form to activate a textbox based on a dropdown selection. I found the below script which works fine on Firefox, Chrome and IE9+, but will not work on IE8.

Script:

<html>
<head>
<script type="text/javascript">
function checkvalue(val)
{
    if(val==="others")
       document.getElementById('color').style.display='block';
    else
       document.getElementById('color').style.display='none'; 
}
</script>
</head>
 
<body>

<select name="color" onchange='checkvalue(this.value)'> 
    <option>pick a color</option>  
    <option value="red">RED</option>
    <option value="blue">BLUE</option>
    <option value="others">others</option>
</select> 
<input type="text" name="color" id="color" style='display:none'/>
 
</body>
 
</html>

Open in new window


I would like this to work in IE8. Any assistance would be greatly appreciated.

Thank you.
0
Comment
Question by:bootneck2222
2 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 39650834
Although valid HTML, you just need to make sure that the names of the select and input are different. Since you use the input's id in your function, I tried this (changed the name of the select) and it works ok now, tested in IE8 and Firefox:
<html>
<head>
<script type="text/javascript">
function checkvalue(val)
{
    if(val==="others")
       document.getElementById('color').style.display='block';
    else
       document.getElementById('color').style.display='none';
}
</script>
</head>
 
<body>

<select name="colorSEL" onchange='checkvalue(this.value)'>
    <option>pick a color</option>  
    <option value="red">RED</option>
    <option value="blue">BLUE</option>
    <option value="others">others</option>
</select>
<input type="text" name="color" id="color" style='display:none'/>
 
</body>
 
</html>

Open in new window

0
 

Author Closing Comment

by:bootneck2222
ID: 39650970
Thank you Robert. I knew it would be something fairly simple.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question