为什么我把js拼成一个字符串打印出来,用单击按钮访问不了。而我把下面的js代码不用拼成一个字符串直接echo出来,怎么能够访问js。 我不知道是怎么回事,请各位帮下忙,谢谢。<?php
include 'conn.php';
include "my.php";
ini_set('default_charset','UTF-8');
header("Content-Type:text/html;charset:UTF-8");
$javascript=<<< JAVASCRIPT
<script language="javascript">
function aa(){alert("eeeeee");
}
//处理onchange事件的函数
function changeValue(selectValue)
{
if (selectValue == "ALL")
{
document.getElementById("sdiv").style.display = "none";
return;
}
else
{
document.getElementById("sdiv").style.display = "";
document.getElementById("sspan").innerHTML = generateSelect(selectValue);
}
}
function generateSelect(inValue)
{
alert(inValue);
if (inValue == "1")
{
JAVASCRIPT;
$javascript.="<select name=\"inputtype\">";
$javascript.="<OPTION value=\"inputtype\" selected>请选择类型:</option>";
// $link=mysql_connect("localhost","root","101219");
// mysql_query("SET CHARACTER SET gb2312");
// mysql_select_db("managemanagerment",$link);
//$z=new mynum();
//$t=$z->getParameterNum($_GET["leibei"], $_GET["w"], $_GET,$page);
// $d=$t["b"];
$sql="SELECT inputtype FROM inputtype where inorout =1"; //$row=mysql_fetch_array($d);
$javascript.="<option value=\"".$row['tname']."\">".$sql."</option>";
$javascript.="</select>"; $javascript.=<<< JAVASCRIPT
}
else
{ }
}
</script>
JAVASCRIPT;
echo $javascript;
echo '<input type="button" name="Submit1" class="bntccanniu" value="取消" onclick="aa();"/>';
?>
include 'conn.php';
include "my.php";
ini_set('default_charset','UTF-8');
header("Content-Type:text/html;charset:UTF-8");
$javascript=<<< JAVASCRIPT
<script language="javascript">
function aa(){alert("eeeeee");
}
//处理onchange事件的函数
function changeValue(selectValue)
{
if (selectValue == "ALL")
{
document.getElementById("sdiv").style.display = "none";
return;
}
else
{
document.getElementById("sdiv").style.display = "";
document.getElementById("sspan").innerHTML = generateSelect(selectValue);
}
}
function generateSelect(inValue)
{
alert(inValue);
if (inValue == "1")
{
JAVASCRIPT;
$javascript.="<select name=\"inputtype\">";
$javascript.="<OPTION value=\"inputtype\" selected>请选择类型:</option>";
// $link=mysql_connect("localhost","root","101219");
// mysql_query("SET CHARACTER SET gb2312");
// mysql_select_db("managemanagerment",$link);
//$z=new mynum();
//$t=$z->getParameterNum($_GET["leibei"], $_GET["w"], $_GET,$page);
// $d=$t["b"];
$sql="SELECT inputtype FROM inputtype where inorout =1"; //$row=mysql_fetch_array($d);
$javascript.="<option value=\"".$row['tname']."\">".$sql."</option>";
$javascript.="</select>"; $javascript.=<<< JAVASCRIPT
}
else
{ }
}
</script>
JAVASCRIPT;
echo $javascript;
echo '<input type="button" name="Submit1" class="bntccanniu" value="取消" onclick="aa();"/>';
?>
{
alert(inValue);
if (inValue == "1")
{ <select name="inputtype"><OPTION value="inputtype" selected>请选择类型:</option><option value="aaa">SELECT inputtype FROM inputtype where inorout =1</option></select>
}
else
{ }
}这种写法对么?
<select name="inputtype"><OPTION value="inputtype" selected>请选择类型:</option>这个写在js
中是什么含义呢?
起码应该是:
document.getElementById("id").innerHTML='<select name="inputtype"><OPTION value="inputtype" selected>请选择类型:</option>'吧?