当前位置:Gxlcms > PHP教程 > 弹出新页面js计算年龄获取php传值

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

时间:2021-07-01 10:21:17 帮助过:17人阅读

<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')"/>

人气教程排行