×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

在这里.请看

本文发表在 rolia.net 枫下论坛<?php
ini_set('display_errors','On');
error_reporting(6135);

include"cred.php";
//$cpart=$_GET['cpart'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>SmartNet Finder</title>
<link rel="STYLESHEET" type="text/css" href="_data/css/admin2.0.css">
<script language="javascript" type="text/javascript">
<!--
//Browser Support Code
function ajaxFunction(qcpt){
var ajaxRequest; // The variable that makes Ajax possible!

try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById('ajaxDiv');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
var cpt =qcpt;

var queryString = "?cpt=" + cpt;
ajaxRequest.open("GET", "smtDat.php" + queryString, true);
ajaxRequest.send(null);
//return false; //page not reload
}


//-->
</script>
</head>

<body >
<!-- <a href="#" onclick="errorbox('msg')">test</a> -->
<?

include"_header.php";
mysql_select_db('tmpDat');
$qsmpart=mysql_query("SELECT `part#` from smartnet
order by 1") or die('query smartparts error '.mysql_error());
?>
<table width="750" cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
<td width="20"></td>
<td width="500">
<img src="_data/images/title_master_db_admin.gif" width="176" height="22" alt="Master Admin" border="0"><br>
&nbsp;<a href="master_db_admin.php">Back</a> | <font class="text_grey">Smartnet Finder</font>
<p><form name="cparts">
<strong>Cisco Part#</strong>&nbsp;&nbsp;
<select name="spart" onchange="ajaxFunction(this.value)">
<option value="">select here or type
<?php
while($r = mysql_fetch_array($qsmpart)){
?>
<option value="<?=$r[0]?>"><?=$r[0]?></option>
<?php
}?>
</select>
<input type="Text" name="cpart" size="29" >
<input type="Button" value="Go" onclick="ajaxFunction(this.form.cpart.value)">
</form></p>
<div id='ajaxDiv'>Your result will display here</div>

</td>
</tr>
</table>
</body>
</html>更多精彩文章及讨论,请光临枫下论坛 rolia.net
Report

Replies, comments and Discussions:

  • 工作学习 / 专业技术讨论 / 问一个PHP AND AJAX 问题.ENTER KEY DOESN'T WORK FOR CALLING AJAX FUNCTION WHEN SUBMIT FORM.请教高手,多谢.
    • 代码帖过来
      • 在这里.请看
        本文发表在 rolia.net 枫下论坛<?php
        ini_set('display_errors','On');
        error_reporting(6135);

        include"cred.php";
        //$cpart=$_GET['cpart'];
        ?>
        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

        <html>
        <head>
        <title>SmartNet Finder</title>
        <link rel="STYLESHEET" type="text/css" href="_data/css/admin2.0.css">
        <script language="javascript" type="text/javascript">
        <!--
        //Browser Support Code
        function ajaxFunction(qcpt){
        var ajaxRequest; // The variable that makes Ajax possible!

        try{
        // Opera 8.0+, Firefox, Safari
        ajaxRequest = new XMLHttpRequest();
        } catch (e){
        // Internet Explorer Browsers
        try{
        ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
        try{
        ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e){
        // Something went wrong
        alert("Your browser broke!");
        return false;
        }
        }
        }
        // Create a function that will receive data sent from the server
        ajaxRequest.onreadystatechange = function(){
        if(ajaxRequest.readyState == 4){
        var ajaxDisplay = document.getElementById('ajaxDiv');
        ajaxDisplay.innerHTML = ajaxRequest.responseText;
        }
        }
        var cpt =qcpt;

        var queryString = "?cpt=" + cpt;
        ajaxRequest.open("GET", "smtDat.php" + queryString, true);
        ajaxRequest.send(null);
        //return false; //page not reload
        }


        //-->
        </script>
        </head>

        <body >
        <!-- <a href="#" onclick="errorbox('msg')">test</a> -->
        <?

        include"_header.php";
        mysql_select_db('tmpDat');
        $qsmpart=mysql_query("SELECT `part#` from smartnet
        order by 1") or die('query smartparts error '.mysql_error());
        ?>
        <table width="750" cellpadding="0" cellspacing="0" border="0" align="center">
        <tr>
        <td width="20"></td>
        <td width="500">
        <img src="_data/images/title_master_db_admin.gif" width="176" height="22" alt="Master Admin" border="0"><br>
        &nbsp;<a href="master_db_admin.php">Back</a> | <font class="text_grey">Smartnet Finder</font>
        <p><form name="cparts">
        <strong>Cisco Part#</strong>&nbsp;&nbsp;
        <select name="spart" onchange="ajaxFunction(this.value)">
        <option value="">select here or type
        <?php
        while($r = mysql_fetch_array($qsmpart)){
        ?>
        <option value="<?=$r[0]?>"><?=$r[0]?></option>
        <?php
        }?>
        </select>
        <input type="Text" name="cpart" size="29" >
        <input type="Button" value="Go" onclick="ajaxFunction(this.form.cpart.value)">
        </form></p>
        <div id='ajaxDiv'>Your result will display here</div>

        </td>
        </tr>
        </table>
        </body>
        </html>更多精彩文章及讨论,请光临枫下论坛 rolia.net