getElementByIdis没有读取值

时间:2017-05-04 08:03:49

标签: javascript

我想从下拉菜单中显示所选月份的记录。我有一个函数,这个函数中的变量必须从不同的函数中选择一个月。

我正在使用getElementById().value从其他函数中读取值。我的申请有3个级别。

1级非常通用,2级被分类,3级非常具体(从2级进一步分类)。我将从1级和2级选择月份,3级应显示相应的数据。通过从级别1阅读getElementById("month").value,级别2工作正常,但级别3从级别1读取getElementById("month").value。以下是我的代码

function level_1() {
  var cur_month = new Date.today().toString("MM");
  cur_month=cur_month.trim();
  var sel_month = "";
  try{
    sel_month=document.getElementById("month_ps").value;
    cur_month = sel_month;
  } catch(err){
    sel_month=cur_month;
  }

  var display = "<div style='color: ffff00'>Month: <select name='month_ps' id='month_ps' value= '"+cur_month+"' style='font-weight: bold' onChange='level_1()'>"; 
  var output = <input type='radio' name='level1' onClick='level2()'>
}

function level_2(){
  var cur_month = new Date.today().toString("MM");
  cur_month=cur_month.trim();
  var sel_month = "";
  try{
    sel_month=document.getElementById("month_ps").value;
    cur_month = sel_month;
  } catch(err){
    sel_month=cur_month;
  }
  var output = <input type='radio' name='level2' onClick='level3()'>
}

function level_3(){
  var cur_month = new Date.today().toString("MM");
  cur_month=cur_month.trim();
  var sel_month = "";
  try{
    sel_month=document.getElementById("month_ps").value;
    cur_month = sel_month;
  } catch(err){
    sel_month=cur_month;
  }
}

0 个答案:

没有答案
相关问题