当前位置: 代码迷 >> JavaScript >> 弹出新页面 js计算岁数 获取php传值
  详细解决方案

弹出新页面 js计算岁数 获取php传值

热度:163   发布时间:2012-10-07 17:28:51.0
弹出新页面 js计算年龄 获取php传值

<script type="text/javascript">

//js 中接受php传过来的值
var tt = <?php echo $tnum; ?>;

  function   ages(str)   
  {   
        var   r   =   str.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);     
        if(r==null)return   false;     
        var   d=   new   Date(r[1],   r[3]-1,   r[4]);     
        if   (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4])   
        {   
              var   Y   =   new   Date().getFullYear();   
              return((Y-r[1]));   
        }   
        return("输入的日期格式错误!");   
  }
  
  //模仿提交 
  function getUrl(url,target)
{

		 var form = document.createElement("FORM");
		 form.method = "POST";
		 form.action = url;
		 if(target) {
		 	form.target = target;
		 }
		 else
		 {
		 	form.target = "_self";
		 }	
		 document.body.appendChild(form);
		 form.submit();	
} 
	var tyear = '20087-10-15';
	if( 3 < ages(tyear) < 6) {
		getUrl('http://baoming010.eduu.com/index/search/term:2/grade:-3/subject:/area:/tname:/status:2','_blank');
	}

</script>
<input type="button" value="提交" onclick="getUrl('http://baoming010.eduu.com/index/search/term:2/grade:-3/subject:/area:/tname:/status:2','_blank')"/>
?
  相关解决方案