欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

弹出新页面 js计算年龄 获取php传值

程序员文章站 2022-03-16 14:04:33
...
<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')"/>