admin管理员组文章数量:1357568
I'm looking for a simple javascscript alert box. I need to be able to pass the alert box a string of text.
Is something like this possible? My syntax is probably wrong.
<html>
<head>
<script type="text/javascript">
function show_alert()
{
alert(my_string_here);
}
</script>
</head>
<body>
<input type="button" onclick="show_alert()" value="Show alert box" string="alert for system number 2" />
</body>
</html>
I'm looking for a simple javascscript alert box. I need to be able to pass the alert box a string of text.
Is something like this possible? My syntax is probably wrong.
<html>
<head>
<script type="text/javascript">
function show_alert()
{
alert(my_string_here);
}
</script>
</head>
<body>
<input type="button" onclick="show_alert()" value="Show alert box" string="alert for system number 2" />
</body>
</html>
Share
Improve this question
asked Nov 4, 2009 at 20:59
shaissshaiss
2,0105 gold badges23 silver badges34 bronze badges
1
- I know my example makes no sense, I'm not a JS guru. thank you Bjorn for the tip, that worked perfect! – shaiss Commented Nov 4, 2009 at 21:10
6 Answers
Reset to default 4<html>
<head>
<script type="text/javascript">
function show_alert(my_string)
{
alert(my_string);
}
</script>
</head>
<body>
<input type="button" onclick="show_alert('This will alert!')" value="Show alert box" string="alert for system number 2" />
</body>
</html>
This makes no sense thou. Better solution:
<html>
<head>
</head>
<body>
<input type="button" onclick="alert('Doh!')" value="Show alert box" string="alert for system number 2" />
</body>
</html>
Try:
<input type="button" onclick="alert('alert for system number 2');" value="Show alert box" />
What are you trying to do? alert('Your string here') should do the trick if you really need an alert.
Yes you can
function testAlert(val){alert(val);}
Yes this is possible
<script type="text/javascript">
function testAlert(val){alert(val);}
</script>
<input type=text onclick='testAlert(this.string)' string="something" value="clik here">
alert("alert for system number 2");
本文标签: variablesPass Javascript Alert a ValueStack Overflow
版权声明:本文标题:variables - Pass Javascript Alert a Value - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744041578a2580759.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论