ajax+php的有关问题
ajax+php的问题
有好几个checkbox循环出来,还有个文本框
- HTML code
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><input name="ckID[]" type="checkbox" id="<?='ckID'.$row['MIS_id']?>" value="<?=$row['MIS_id']?>" onclick="showInfor(this.value)"> <div id="txtHint"> <input name="txtid" type="text" id="txtid"> </div>
以下是AJAX:
- JScript code
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->function showInfor(str) { //document.getElementById("txtid").value=str; //var str = document.geElementById("ckID").value; //document.write(str); var xmlhttp; if (id.length==0) { document.getElementById("txtid").value=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { //document.getElementById("show").innerHTML=xmlhttp.responseText; document.getElementById("txtid").value=xmlhttp.responseText; } } xmlhttp.open("GET","showSettle.php?q="+str,true); xmlhttp.send(); }
然后是对于的php页面
- PHP code
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->$db = mysql_connect("localhost","root","1234"); mysql_select_db("it database",$db); $q=$_GET['q']; // connecting to database and stuff... echo $q; $temp = mysql_query("SELECT MIS_id FROM materialinstorage WHERE MIS_id = '$q' "); echo $temp; $row = mysql_fetch_array($temp); $id =$row['MIS_id']; echo $id;
现在好像是php那页面不执行,没反应啊。
我在ajax里执行document.write(str);可以得到数据的。
请问哪里出错了呀
------解决方案--------------------
弄个google浏览器或者firebug一看就知道了!
------解决方案--------------------
------解决方案--------------------
if (id.length==0)
这个 id 没有定义
------解决方案--------------------
一步一步调试。首先alert(xmlhttp.responseText); 看能不能弹出php端的输出。
------解决方案--------------------
- HTML code
document.getElementById("txtid").value="";应该是这句,这是什么错啊 //跟你这句没关系的,这句只是设置文本框中的值为空 if (id.length==0){ //是这段的处理,主要是id.length这个没有定义,不懂这段做什么,是判断复选框是否被选? 检查下这段 document.getElementById("txtid").value=""; return; } <div class="clear"> </div>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Solutions for document.cookie not being obtained: 1. Browser privacy settings; 2. Same-origin policy; 3. HTTPOnly Cookie; 4. JavaScript code error; 5. Cookie does not exist or expires; 6. Cross-domain issues; 7. Viewer mode; 8. Server problems; 9. JavaScript execution timing; 10. Check console log, etc.

On September 3, version 1.5 of the Grand Theft Auto VI document which provides a detailed overview of everything that is known about the game to date. The updated version of the document was announced in a trailer published on X (formerly Twitter).??

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

getElementById can obtain the corresponding HTML element through the id attribute of the element, and then operate and modify it conveniently. Whether it is to dynamically change the content and style of an element or add an event listener, getElementById is a very commonly used method.

Introduction to the Document object in JavaScript and code examples: In JavaScript, the Document object is an interface that represents the entire HTML document. It provides access and operation methods to the HTML document. This article will introduce the common methods and properties of the Document object and provide some specific code examples. getElementById method getElementById is an important method of the Document object, used to

First give the web page address: https://wall.alphacoders.com/featured.php?lang=Chinese Main steps: Use the connect method of Jsoup to obtain the Document object Stringhtml="https://wall.alphacoders.com/featured.php ?lang=Chinese";Documentdoc=Jsoup.connect(html).get();If the content is too long, it will not be displayed again. Let’s take this section as an example: AboutUsFAQPrivacyP

Common document properties and methods: Properties: 1. document.title: Get or set the title of the document, usually displayed on the title bar or label of the browser; 2. document.URL: Get the complete URL of the document; 3. document. documentElement: Get the root element of the document, usually the <html> element; 4. document.body: Get the <body> element of the document; 5. document.head, etc.

不用数据库来实现用户的简单的下载,代码如下,但是却不能下载,请高手找下原因,文件路劲什么的没问题。
