我需要获取用户的屏幕分辨率并将其保存到我的数据库中。使用Javascript设置隐藏字段值;使用PHP post方法发送数据
我在做的是这样的:我有一个Javascript函数调用与获取信息并将值传递给隐藏的窗体字段。这是函数:
<script type="text/javascript">
function getUserData(){
var s_width=screen.width
var s_height=screen.height
document.getElementById('screen_width').value=s_width
document.getElementById('screen_height').value=s_height
}
</script>
而且形式:
<form name="login" id="login" action="memberlogin.php" method="post">
<input type="hidden" id="screen_width" name="screen_width">
<input type="hidden" id="screen_height" name="screen_height">
<table style="margin-top:9px;">
<tr><td width="200px"><input type="text" name="username" style="width:100%"/></td></tr>
<tr><td width="200px"><input type="password" name="password" style="width:100%"/></td></tr>
<tr><td><input type="submit" name="submit" value="Log In" /></td></tr>
</table>
</form>
的形式提交到同一页面。当我点击“提交”并尝试回显$ _POST ['screen_width']和$ _POST ['screen_height']的值时,没有任何反应。但是当我重新提交时,价值就在那里。有人能告诉我我做错了什么吗?如果您有其他解决方案,我们同样会感激。
写你的php代码太多.. – 2012-01-05 11:15:30
这段代码看起来正确..必须在php的一些概率 – 2012-01-05 11:16:22
你的函数在哪里调用? – amccausl 2012-01-05 11:16:24