云企logo

自定义表单JS方式添加留言时间和提交IP

更新日期:2022-04-02  
首先在自定义表单创建ip和liuyantime两个字段,用文本类型就行。然后在对应的表单添加以下代码:
<input type="hidden" name="ip" id="ip" value="">
<input type="hidden" name="liuyantime" id="liuyantime" value=""> 
<script type="text/javascript">
     window.onload = function(){
     var nowDate = new Date();
     var str = nowDate.getFullYear()+"-"+(nowDate.getMonth() + 1)+"-"+nowDate.getDate()+" "+nowDate.getHours()+":"+nowDate.getMinutes()+":"+nowDate.getSeconds();
     document.getElementById("liuyantime").value=str;
     }
</script>
<script type="text/javascript" src="http://pv.sohu.com/cityjson/getip.aspx" charset="utf-8"></script>
<script type="text/javascript">
var ip=returnCitySN.cip+"-"+returnCitySN.cname;
document.getElementById("ip").value=ip;
</script>

 

上一篇:织梦CMS导入数据库,在哪修改数据库配置文件?

下一篇:pbootcms一个列表中调取多个栏目的的内容
首页