Solved

Activiate a textbox on dropdown selection not working in IE8

Posted on 2013-11-15
2
445 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
Comment Utility
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
Comment Utility
Thank you Robert. I knew it would be something fairly simple.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now