Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Activiate a textbox on dropdown selection not working in IE8

Posted on 2013-11-15
2
Medium Priority
?
476 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
[X]
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
2 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

610 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