我这有个表单 里面有几个隐藏的元素初始值是空的 会通过js修改这几个元素的值 但是提交后php里获取时还是空值 这是什么问题 请各位大神指教
回复讨论(解决方案)
贴代码出来啊 看了代码才能研究
<script> <br /> var xhr; <br /> function createXMLHttpRequest() <br /> { <br /> if(window.ActiveXObject) <br /> { <br /> xhr = new ActiveXObject("Microsoft.XMLHTTP"); <br /> } <br /> else if(window.XMLHttpRequest) <br /> { <br /> xhr = new XMLHttpRequest(); <br /> } <br /> } <br /> <br /> function selectFile(id) <br /> { <br /> document.getElementById(id).click(); <br /> } <br /> <br /> function UpladFile(id,ids,img) <br /> { <br /> setCookie("ids",ids); <br /> setCookie("img",img); <br /> var fileObj = document.getElementById(id).files[0]; <br /> var FileController = 'upload.php'; <br /> var form = new FormData(); <br /> form.append("myfile", fileObj); <br /> createXMLHttpRequest(); <br /> xhr.onreadystatechange = handleStateChange; <br /> xhr.open("post", FileController, true); <br /> xhr.send(form); <br /> } <br /> <br /> function handleStateChange() <br /> { <br /> if(xhr.readyState == 4) <br /> { <br /> if (xhr.status == 200 || xhr.status == 0) <br /> { <br /> var result = xhr.responseText; <br /> var json = eval("(" + result + ")"); <br /> var n = (json.file.split('\\')).length-1; <br /> var newurl = json.file; <br /> for(var i = 0; i < n; i++) <br /> { <br /> newurl = newurl.replace("\\","/"); <br /> } <br /> newurl = "http://eshb.cheexun.net" + newurl; <br /> alert("上传成功"); <br /> var ids = getCookie("ids"); <br /> var img = getCookie("img"); <br /> document.getElementById(ids).src = newurl; <br /> document.getElementById(img).src = newurl; <br /> } <br /> } <br /> } <br /> function setCookie(name,value) <br /> { <br /> var Days = 30; <br /> var exp = new Date(); <br /> exp.setTime(exp.getTime() + Days*24*60*60*1000); <br /> document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString(); <br /> } <br /> <br /> <br /> function getCookie(name) <br /> { <br /> var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)"); <br /> if(arr=document.cookie.match(reg)) <br /> return unescape(arr[2]); <br /> else <br /> return null; <br /> } <br /> </script>
里面有几个隐藏的元素初始值是空的 会通过js修改这几个元素的值 但是提交后php里获取时还是空值
js没赋值到,alert输出看看
里面有几个隐藏的元素初始值是空的 会通过js修改这几个元素的值 但是提交后php里获取时还是空值
js没赋值到,alert输出看看
我通过开发者工具观察已经是赋值了
里面有几个隐藏的元素初始值是空的 会通过js修改这几个元素的值 但是提交后php里获取时还是空值
js没赋值到,alert输出看看
好了 谢谢提醒 知道什么问题 真是太粗心
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn