免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1848 | 回复: 2
打印 上一主题 下一主题

onlick if else 的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-24 01:08 |只看该作者 |倒序浏览
  1. <script type="text/Javascript">
  2. function update_change()
  3. {
  4.          update=document.getElementById('update').value;
  5.          week_date = new Date();
  6.         day = week_date.getDay();
  7.         if (day == "0")
  8.         {
  9.                 day = 7 ;
  10.         }
  11.         month_day = week_date.getDate();
  12.         // now_str = week_date.getFullYear()+"-"+ (week_date.getMonth()+1)+"-"+week_date.getDate();
  13.         differ = 7 - day + 1;
  14.         
  15.          endtime = new Date();

  16.         arr = update.split("-");
  17.         update_format = new Date(Date.UTC(arr[0],arr[1]-1,arr[2],'0','0','0'));
  18.         now_format = new Date(Date.UTC(week_date.getFullYear(),(week_date.getMonth()),week_date.getDate(),'0','0','0'));
  19.         
  20.         update_format = (update_format.getTime()/1000);
  21.         endtime_format = (now_format.getTime()/1000+differ*24*60*60);
  22.         //alert(endtime_format);
  23.         //alert("end "+endtime_format+" upd "+update_format);
  24.         if (update_format >= endtime_format)
  25.         {      
  26.                 plan = "是";
  27.                  sl_plan_obj = document.getElementById('select_isplan');
  28.                 sl_plan_obj.options.length=0;
  29.                 sl_plan_obj.options.add(new Option(plan,"value"));
  30.                                 alert("是")
  31.         }
  32.         else
  33.         {
  34.                 plan = "否";
  35.                 sl_plan_obj = document.getElementById('select_isplan');
  36.                 sl_plan_opbj.options.length=0;
  37.                 sl_plan_obj.options.add(new Option(plan,"value"));
  38.                 alert("否");
  39.         }
  40.         
  41. }
  42. </script>

  43. <td height="28" >变更日期:
  44. <input class="update" name="update" type="text" id="update" >
  45. <font color="#FF0000">*</font>
  46. <input type="button" id="time_sure" name="time_sure" value="确定" onclick="update_change();"> </td>
  47. <td height="28" ><label>是否计划:
  48. <select class="sl_normal"  name="select_isplan" id="select_isplan">
  49.               <option>是</option>
  50.               <option>否</option>
  51.           </select></label></td>
复制代码
当我输入日期  2011-12-28  这样的形式
option就会删除  增加一个是或者否选项

可是这里我的原因是if 块里面的会执行   else永远都不会执行。。。条件逻辑我测试过是对的
不知道为什么。。。不知道俺说的清楚清楚。。求各位帮下

论坛徽章:
0
2 [报告]
发表于 2011-12-25 18:14 |只看该作者
顶上去- -

论坛徽章:
0
3 [报告]
发表于 2011-12-25 21:57 |只看该作者
自己手误 写错了个对象。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP