Kla*_*sos 1 javascript php alert
我需要show_alert()在PHP代码中引入JavaScript警报功能.怎么做到这一点?
script type="text/javascript">
function show_alert() {
var msg = "No solution found.";
alert(msg);
}
</script>
<?php
//...
$outputs = -1;
if ($outputs == -1) {
echo '<script type="text/javascript"> show_alert(); </script>';
} else {
?>
<table width="100%">
<tr>
<td width="100%">
<div class="scrollbar" id="chart">
<img src="ganttchart.php">
</div>
</td>
</tr>
</table>
<?php
}
?>
Run Code Online (Sandbox Code Playgroud)
试试这个,它回显show_alert(); 在PHP中:
<script type="text/javascript">
function show_alert() {
var msg = "No solution found";
alert(msg);
}
</script>
<?php
//...
$output = run_function();
if ($output == -1) {
echo '<script type="text/javascript"> show_alert(); </script>';
}
?>
Run Code Online (Sandbox Code Playgroud)