Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Works in IE, not in Firefox or Safari 3

Status
Not open for further replies.

Trusts

Programmer
Feb 23, 2005
268
US
Picky, pesky browsers - keep me hopping!

This works in IE, but only in IE:

<script language="JavaScript" type="text/javascript">
function clear1() {
document.getElementById('specid').options.value = "None";
document.getElementById('office_id').options.value = "None";
}
function clear2() {
document.getElementById('docid').options.value = "None";
document.getElementById('office_id').options.value = "None";
}
function clear3() {
document.getElementById('docid').options.value = "None";
document.getElementById('specid').options.value = "None";
}
</script>

There are three dropdowns on a page - one each for doctors, specialies, and locations. This is a search page and the point is that when a selection is made in a dropdown, the other two revert back to the first item, which has the text "Select from list" and the Value="None"


The code is called when a dropdown is changed, like this:
<select name="docid" onchange="clear1()">

So, for example, a doctor is selected and the specialty and location dropdowns go back to saying "Select from list"

This works in IE and has no effect in the other browsers. Any ideas how to fix this?

Thanks!
KB
 
Is the "select from list" option the very first option in the drop-down?

If so, this should suffice:

Code:
<script language="JavaScript" type="text/javascript">
<!--
function clear1() {
    document.getElementById('specid').selectedIndex = 0;
    document.getElementById('office_id').selectedIndex = 0;
}
function clear2() {
    document.getElementById('docid').selectedIndex = 0;
    document.getElementById('office_id').selectedIndex = 0;
}
function clear3() {
    document.getElementById('docid').selectedIndex = 0;
    document.getElementById('specid').selectedIndex = 0;
}
//-->
</script>

 
The options is an array, and therefore does not have a SINGLE value. For years IE has had all sorts of things built in to second guess poor programming, where Firefox expects the programmers to get it right themselves.

Lee
 
><select name="docid" onchange="clear1()">
[tt]<select name="docid" [red]id="docid"[/red] onchange="clear1()">[/tt]
Same for specid and office_id. Then continue to use cLFlaVA's lines.
 
Thanks, I forgot to use id attribute. Works fine now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top