The following code snippet works in IE, but not Firefox 2.0.0.10. The parts that access text boxes work great. I can see the selectedIndex's value for the two drop-downs, but cannot retrieve the text of the selected item for either drop-down. Specifically, the first alert displays the value of the URL string to that point. The second alert doesn't display.

I would really appreciate any help with this one!

var URL = "http://www.rms4sd.com/media_and_resource_center/dev/inputResource.pl?date=" + document.data_entry.date.value;
URL += "&title=" + document.data_entry.media_title.value;
URL += "&URL=" + document.data_entry.URL.value;
alert(URL);

URL += "&topic=" + document.data_entry.topic.options(document.data_entry.topic.selectedIndex).text;
URL += "&format=" + document.data_entry.format.options(document.data_entry.format.selectedIndex).text ;
alert(URL);

Read this.

As far as your problem is concerned, document.data_entry.topic.options(document.data_entry.topic.selectedIndex).text; should be document.data_entry.topic.options[document.data_entry.topic.selectedIndex].value ;

The above way of referencing form elements is pretty inefficient and partly incorrect which is what the tutorial I posted aims at explaining.

Thanks for your excellent tutorial on accessing the elements of a form! Thanks also for pointing out my referencing error.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.