I
iannorton
Hi,
I've made a simple drop down toggle switch that switches a text box
from one to another.
The script runs fine in IE, but refuses to work in IE, not even
pointing me at an error.
Wondered if anyone could help?
<script type="text/javascript">
function toggleBox(szDivID)
{
if(document.getElementById) // Only Gen 5 browsers +
{
var obj = document.getElementById(szDivID);
if (obj.name == 'nameForm')
{
var obj1 = document.getElementById('jobForm')
obj1.style.display = "none";
var obj2 = document.getElementById('nameForm')
obj2.style.display = "block";
}
if (obj.name == 'jobForm')
{
var obj1 = document.getElementById('nameForm')
obj1.style.display = "none";
var obj2 = document.getElementById('jobForm')
obj2.style.display = "block";
}
}
}
</script>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
#jobForm
{
display: none;
}
#nameForm
{
display: block;
}
</style>
</head>
</body>
<form action="" method="get" name="trentws">
<select id="searchtype" style="width:200px">
<option value="By name" onClick="toggleBox('nameForm');"
selected="selected">Search by name</option>
<option value="By job title" onClick="toggleBox('jobForm');">Search
by job title</option>
</select>
<input type="text" autocomplete="off" name="nameForm" value="name"
id="nameForm" style="width:200px" />
<input type="text" autocomplete="off" name="jobForm" value="job"
id="jobForm" style="width:200px" />
</form>
Any help would be greatly appreciated, it should all be running in
standards compliance mode.
Ian
I've made a simple drop down toggle switch that switches a text box
from one to another.
The script runs fine in IE, but refuses to work in IE, not even
pointing me at an error.
Wondered if anyone could help?
<script type="text/javascript">
function toggleBox(szDivID)
{
if(document.getElementById) // Only Gen 5 browsers +
{
var obj = document.getElementById(szDivID);
if (obj.name == 'nameForm')
{
var obj1 = document.getElementById('jobForm')
obj1.style.display = "none";
var obj2 = document.getElementById('nameForm')
obj2.style.display = "block";
}
if (obj.name == 'jobForm')
{
var obj1 = document.getElementById('nameForm')
obj1.style.display = "none";
var obj2 = document.getElementById('jobForm')
obj2.style.display = "block";
}
}
}
</script>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
#jobForm
{
display: none;
}
#nameForm
{
display: block;
}
</style>
</head>
</body>
<form action="" method="get" name="trentws">
<select id="searchtype" style="width:200px">
<option value="By name" onClick="toggleBox('nameForm');"
selected="selected">Search by name</option>
<option value="By job title" onClick="toggleBox('jobForm');">Search
by job title</option>
</select>
<input type="text" autocomplete="off" name="nameForm" value="name"
id="nameForm" style="width:200px" />
<input type="text" autocomplete="off" name="jobForm" value="job"
id="jobForm" style="width:200px" />
</form>
Any help would be greatly appreciated, it should all be running in
standards compliance mode.
Ian