This article is mainly for JS to get the value of the selected items and text implementation code is introduced, the need for friends can come to the reference, I hope to help you.
JS get the value of the dropdown box and text online provides 2 methods: But some people are very irresponsible, they did not consider the differences between the browser caused by the error, resulting in a lot of novice thinking about a half-day can not find a mistake! Below I summarize under Firefox and IE get dropdown box to select the value and text: 1. Both IE and Firefox support methods: Get text code as follows: Var Obj=document.getelementbyid (' select_template '); var text= obj.options[obj.selectedindex].text;//get text var Obj=document.getelementbyid ("Select_template"); for (i=0;i<obj.length;i++) {//dropdown box length is the number of his options if (obj [i].selected==true) { var text=obj[i].text;//get text } The previous method is relatively concise 2. IE support Firefox does not support: code as follows: Var Obj=document.getelementbyid (name); for (i=0;i<obj.length;i++) { if (obj[i].selected==true) { & nbsp var text= Obj[i].innertext; { } Get value method ie and Firefox general: Var Value=document.gete Lementbyid ("Select_Template "). value;//Get Value Summary: In fact, the main is IE and Firefox support the value and Text properties, Firefox does not support innertext properties. JS implement current page open a new link: