2010-04-01 142 views
0

它的一种愚蠢的问题。但我不知道我犯了什么错误。如果有人可以帮助。将变量传递给函数

<html> 
<head> 
<script type="text /vbscript"> 
function zips(s) 
    document.write(s) 
end function 
</script> 
</head> 

<body> 
<script type="text/vbscript"> 
dim x,y 
x="sushant" 
<button onclick="zips(x)" id=button1 name=button1>clickme</button> 
</script> 
</body> 
</html> 

对不起,我不知道如何格式化它。但我没有得到所需的输出。任何帮助非常赞赏

回答

3

您的button标签应该是以外的script标签。

<script type="text/vbscript"> 
dim x,y 
x="sushant" 
</script> 
<button onclick="zips(x)" id=button1 name=button1>clickme</button> 

该按钮不是脚本的一部分,而是HTML的一部分。

+0

+1:不错的选择:) – Sarfraz 2010-04-01 08:46:54

+0

噢。感谢名单。这是一个愚蠢的错误。 – sushant 2010-04-01 08:48:48