开发者

Pass Javascript Alert a Value

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>


<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");

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜