PHP 单击单选,提交查询,并返回结果问题 又一个分不清客户端脚本与服务端脚本的....................................去了解一下WEB程序的运作原理先. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 呵呵,checked()怎么跑到php去了?客户端的操作!<script>checked(){.....}</script> 必须用脚本阿 请问怎么转啊,麻烦告诉一下。我想把取出的值直接放在 文本框里实现编辑的功能。 还有 PHP不也是脚本么? <script>function chk(m){ chk1.show.value=m;}</script><form name="chk1"><input type="radio" value="0" name="R1" onclick="chk(this.value)"> 集团介绍<input type="text" name="show" value=""></form> LZ,你是用PHP5的吧。POST变量不再可以直接那样使用了。因为在PHP5中默认的全局变量是关掉的。(安全起见)要引用提交表单的值要用_POST如:你的值应这样使用$R1=$_POST['R1'];同样,如果是通过GET方式传过来的话就要用$R1=$_GET['R1']; 6楼 : 您没明白我的意思 我是想传进去值 等同时触发 SQL语句进行查询把 ,查询的结果写在文本框里。7楼 : 我就是想点单选的同时,在文本框里写出响应的值。 不想提交,那样使用不方便 ,我要做的是相当于编辑文档的功能。 lz可以稍微研究一下ajax,google一下,copy一下代码,你的需求不复杂。 楼上 :ajax GOOGLE搜索什么好? http://wiki.moztw.org/index.php/AJAX_%E4%B8%8A%E6%89%8B%E7%AF%87入门篇。你可以看看。 谁在来帮帮我 AJAX实在是不会用阿 <form name="showValue" method="POST"><input type="radio" value="1" name="R1" onClick="makeRequest('2.php?id='+this.value)"> 集团介绍<input type="radio" name="R1" value="2" onClick="makeRequest('2.php?id='+this.value)"> 公司介绍<input type="radio" name="R1" value="3" onClick="makeRequest('2.php?id='+this.value)">总经理致词<p> <span lang="zh-cn">公司业务页面<input type="text" name="show" value=""></form>比如你要根据表单的value去查询数据库,姑且设为1,2,3其中makeRequest就触发了ajax事件,2.php是数据查询页面2.php=============<?$conn = mysql_connect(.......);mysql_select_db(.....,$conn);$sql = "select * from table where id=".$_GET['id'];$rs = mysql_query($sql);$result = mysql_fetch_row($rs);print_r($result);?> 表单页面为1.php,数据查询为2.php1.php(给你那个链接写的蛮清楚的)==============<script type="text/javascript" language="javascript"> var http_request = false; function makeRequest(url) { http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Giving up :( Cannot create an XMLHTTP instance'); return false; } //定义system -> clint回值函数名 http_request.onreadystatechange = alertContents;//回调函数 //send a request http_request.open('POST', url, true); http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); http_request.send(null); } function alertContents() { if(http_request.readyState == 3) document.getElementById("AjaxCheck").innerHTML ='...'; if (http_request.readyState == 4) {//状态4为服务器已经传回信息 //0 (還沒開始) //1 (讀取中) //2 (已讀取) //3 (資訊交換中) //4 (一切完成) if(http_request.status == 200) {//200表示状态可供读取 showValue.show.value = http_request.responseText;//将查询结果写入name为show的表单 } else { alert('There was a problem with the request.'); } } }</script><form name="showValue" method="POST"><input type="radio" value="1" name="R1" onClick="makeRequest('2.php?id='+this.value)"> 集团介绍<input type="radio" name="R1" value="2" onClick="makeRequest('2.php?id='+this.value)"> 公司介绍<input type="radio" name="R1" value="3" onClick="makeRequest('2.php?id='+this.value)">总经理致词<p>& nbsp;<span lang="zh-cn">公司业务页面<input type="text" name="show" value=""></form> 此情况是假设你的radio值为数据库表中id字段。 呵呵,多给点分给 foolbirdflyfirst(湖水清澈) 吧 单说程序:那个check()函数应该是js的函数吧通过onselect不可能直接调用php的函数吧,两个应该不是一回事啊!foolbirdflyfirst(湖水清澈)的那个程序正解!最近经常看不懂别人的程序,不知道是不是自己先入为主啊! php 扩展 perl 放上外网服务器登录不了 求iconv的替代函数 怎么限制上传的文件只能是wav格式? 高分求购啊!!!!! 一般服务器需要安装什么库文件?拿出我12分之8来提问! 我对php4中说的换行有疑问? winmysqladmin 1.0 问题 请教这个函数 php如何接收json 发送邮件需要什么组件吗?本地不行传到空间就可以发 php怎么取得别的网站的一个页面并输出在IE中,
客户端的操作!
<script>
checked()
{
.....
}
</script>
还有 PHP不也是脚本么?
function chk(m)
{
chk1.show.value=m;
}
</script>
<form name="chk1">
<input type="radio" value="0" name="R1" onclick="chk(this.value)"> 集团介绍
<input type="text" name="show" value="">
</form>
7楼 : 我就是想点单选的同时,在文本框里写出响应的值。 不想提交,那样使用不方便 ,我要做的是相当于编辑文档的功能。
入门篇。你可以看看。
<input type="radio" value="1" name="R1" onClick="makeRequest('2.php?id='+this.value)"> 集团介绍
<input type="radio" name="R1" value="2" onClick="makeRequest('2.php?id='+this.value)"> 公司介绍
<input type="radio" name="R1" value="3" onClick="makeRequest('2.php?id='+this.value)">总经理致词<p> <span lang="zh-cn">公司业务页面
<input type="text" name="show" value="">
</form>
比如你要根据表单的value去查询数据库,姑且设为1,2,3
其中makeRequest就触发了ajax事件,2.php是数据查询页面
2.php
=============
<?
$conn = mysql_connect(.......);
mysql_select_db(.....,$conn);
$sql = "select * from table where id=".$_GET['id'];
$rs = mysql_query($sql);
$result = mysql_fetch_row($rs);
print_r($result);
?>
1.php(给你那个链接写的蛮清楚的)
==============
<script type="text/javascript" language="javascript">
var http_request = false; function makeRequest(url)
{ http_request = false; if (window.XMLHttpRequest)
{ // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType)
{
http_request.overrideMimeType('text/xml');
}
}
else if (window.ActiveXObject)
{ // IE
try
{
http_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
} if (!http_request)
{
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
//定义system -> clint回值函数名
http_request.onreadystatechange = alertContents;//回调函数
//send a request
http_request.open('POST', url, true);
http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
http_request.send(null); } function alertContents()
{
if(http_request.readyState == 3) document.getElementById("AjaxCheck").innerHTML ='...'; if (http_request.readyState == 4)
{//状态4为服务器已经传回信息
//0 (還沒開始)
//1 (讀取中)
//2 (已讀取)
//3 (資訊交換中)
//4 (一切完成)
if(http_request.status == 200)
{//200表示状态可供读取
showValue.show.value = http_request.responseText;//将查询结果写入name为show的表单
}
else
{
alert('There was a problem with the request.');
}
} }
</script>
<form name="showValue" method="POST">
<input type="radio" value="1" name="R1" onClick="makeRequest('2.php?id='+this.value)"> 集团介绍
<input type="radio" name="R1" value="2" onClick="makeRequest('2.php?id='+this.value)"> 公司介绍
<input type="radio" name="R1" value="3" onClick="makeRequest('2.php?id='+this.value)">总经理致词<p>& nbsp;<span lang="zh-cn">公司业务页面
<input type="text" name="show" value="">
</form>
通过onselect不可能直接调用php的函数吧,两个应该不是一回事啊!
foolbirdflyfirst(湖水清澈)的那个程序正解!
最近经常看不懂别人的程序,不知道是不是自己先入为主啊!