2,如果确实要让整个js文件用到某个参数值,请用全局变量。
就是在html中这样写<script type="text/javascript">var k="abc"</script>
这样,js中使用k,可以获得他的值。
可以这样:
……
fd.append('Filedata', fm)
fd.append('id', 5)
fd.append('sid', 8)
obj.open("post", "upload.php")
……
或者这样:
……
obj.open("post", "upload.php?id=5&sid=8")
……
前一种方式,在upload.php中要通过$_POST['id']来获取参数,而后一种方式,则通过$_GET['id']来获取参数值。
protected void SelectOne(string str){
string strs = "select * from MT_Product where P_Name like str"
sql.Product(strs) //此方法执行并返回结果
}
前台js代码
function Button2_onclick() {
var TextBox1=document.getElementById ('Text1') //取出textbox里的内容.
if(TextBox1.value=="")
{
alert('不能为空!')
return false
}
else
{
<%=SelectOne(Text1.Text) %> //此处调用后台方法.
}