首页上一页 1 下一页尾页 1 条记录 1/1页
急求助:在html如何获取javascript中的变量值
发表在PHP图书答疑
2014-10-20
是否精华
是
否
版块置顶:
是
否
<----静态页面---->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0-rc1.js"></script>
</HEAD>
<BODY>
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
url:"sms.php",type: "GET",dataType: "text",success: function(data){
alert(data);//$a的值
document.getElementById("txt3").value=data;
}
})
})
function calculate(){
document.getElementById("txt3").value=data;
}
</script>
<input type="text" name="txt3" size="10"><input type="button" name="btn" value="计算" onclick="calculate()">
</BODY>
</HTML>
<----sms.php---->
<?php
session_start();
$f_num = '1';
$f_num2 = '2';
$f_num3 = '3';
$f_num4 = '4';
$f_num5 = '5';
$f_num6 = '6';
$f_num7 = '7';
$f_num8 = '8';
$l_num = '9';
$first = $daili_session.$f_num;
$select = "select * from deayou_users where daili between $first and $last";
// print_r($select); exit;
$query = mysql_query($select);
while ($row = mysql_fetch_assoc($query)) {
$res[] = $row;
// print_r($res); exit;
}
foreach($res as $key => $value){
echo $value['daili'];
$a = $value['daili'];
echo $a;
?>
在上面的代码中,表格txt3如何获取到data这个值也就是PHP页传过来的数组值,或者最好是鼠标焦点移到txt3时点一下框就能获取javascript中的变量值,请老师们帮助提供代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0-rc1.js"></script>
</HEAD>
<BODY>
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
url:"sms.php",type: "GET",dataType: "text",success: function(data){
alert(data);//$a的值
document.getElementById("txt3").value=data;
}
})
})
function calculate(){
document.getElementById("txt3").value=data;
}
</script>
<input type="text" name="txt3" size="10"><input type="button" name="btn" value="计算" onclick="calculate()">
</BODY>
</HTML>
<----sms.php---->
<?php
session_start();
$f_num = '1';
$f_num2 = '2';
$f_num3 = '3';
$f_num4 = '4';
$f_num5 = '5';
$f_num6 = '6';
$f_num7 = '7';
$f_num8 = '8';
$l_num = '9';
$first = $daili_session.$f_num;
$select = "select * from deayou_users where daili between $first and $last";
// print_r($select); exit;
$query = mysql_query($select);
while ($row = mysql_fetch_assoc($query)) {
$res[] = $row;
// print_r($res); exit;
}
foreach($res as $key => $value){
echo $value['daili'];
$a = $value['daili'];
echo $a;
?>
在上面的代码中,表格txt3如何获取到data这个值也就是PHP页传过来的数组值,或者最好是鼠标焦点移到txt3时点一下框就能获取javascript中的变量值,请老师们帮助提供代码