Re: simple code for selecting matching text in a listbox



..nLL escribió:
got below script, works fine with IE but fails on opera. my js knowledge is very limited and can't find whats wrong with it.

It doesn't work in Firefox either. So I'd say it only works in IE.


var S = document.getElementById("mymonth");

This line finds an HTML tag with id="mymonth". There isn't any on the page. Replace it with:

var S = document.forms["myform"].mymonth;

This way you call a form element with name "mymonth" in a form with name "myform":

<form method="post" name="myform" action="default.asp">
<p>
Select Month: <select name="mymonth"

Same here:

onChange="document.getElementById('myday').selectedIndex=0">

onChange="document.forms['myform'].myday.selectedIndex=0"


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
.