日期:2014-05-16  浏览次数:20393 次

用JS得到smarty上的下拉框值
<select   name=endYear   onChange= "refreshPostEndDate() ">
  {html_options     options=$year_options   selected=$endYear   class= "trans_form "}
</select>


function   refreshPostEndDate()
{
var   temp   =   document.getElementsByName( "endYear ");

请问怎样才能得到页面上select的信息,我想得到所有选项以及所选的值
谢谢

------解决方案--------------------
var temp = document.getElementsByName( "endYear ").options[document.getElementsByName( "endYear ").selectedIndex].value;
------解决方案--------------------
var obj = document.getElementsByName( "endYear ");
var temp = obj.value; //所选值

var len = obj.options.length;

for(var i = 0; i < len; i++)alert(obj.options[i].value);