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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

works with IE but not Firefox help

Status
Not open for further replies.

ev66

Programmer
Oct 8, 2006
2
GB
when i use the following function, it will only work in Internet explorer and not Firefox-

function myfunc(){
a=document.select1;
b=a.options[a.selectedIndex].value;
alert ("hello")
}

The function stops and does not display the alert.
it works in both browsers if i put the selectbox 'select1' in a form, but i don't want to do this-

this works-
function myfunc(){
a=document.form1.select1;
b=a.options[a.selectedIndex].value;
alert ("hello")
}


Is there a work around so i do not have to use a form ?
Thank you.
 
Yes - give the select element an ID:

Code:
<select [!]id="someIdValue">

and then use "getElementById" to refer to the element:

Code:
a = document.getElementById('someIdValue');

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
thanks for your quick answer,
it works ok now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top