programming.name Posted June 2, 2010 Share Posted June 2, 2010 Hi, Please consider the following chunk of code: <FORM NAME="nav"> <SELECT NAME="SelectURL" onChange= "document.location.href= document.nav.SelectURL.options[document.nav.SelectURL.selectedIndex].value"> <OPTION VALUE="" SELECTED>Please select a link: <OPTION VALUE="http://www.example.com"> Go to somewhere </SELECT> </FORM> From the code above, we have something like: document.location.href= document.nav.SelectURL.options[document.nav.SelectURL.selectedIndex].value. Could you please explain about the code after the "document.location.href=" elemnet by element? I can baerly understand why this code could link to somewhere. Thanks. Link to comment https://forums.phpfreaks.com/topic/203591-javascript-object-oriented-concepts/ Share on other sites More sharing options...
dabaR Posted June 2, 2010 Share Posted June 2, 2010 document.location.href= document.nav.SelectURL.options[document.nav.SelectURL.selectedIndex].value Let's do it backwards: .value = the value of options[document.nav.SelectURL.selectedIndex] = the selected option of (this is basically a lookup into an array, array[index]) document.nav.SelectURL = the SelectURL select box, that is inside the nav form, that is inside the document(the whole HTML document) So all in one sentence: The value of the selected option of the SelectURL select box, that is inside the nav form, that is inside the document = document.nav.SelectURL.options[document.nav.SelectURL.selectedIndex].value Hope that helps! -- Dan Bernardic http://dan.bernardic.ca Link to comment https://forums.phpfreaks.com/topic/203591-javascript-object-oriented-concepts/#findComment-1066461 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.