短片
此代码有效:
<script type="text/javascript">
bootbox.alert("Hello world!");
</script>
此代码无效:
<script type="text/javascript">
bootbox.alert("Hello
world!");
</script>
如果您要问我为什么需要它,就像第二个那样,那是因为该值将基于具有多行代码的textarea,我不知何故需要使用bootbox运行多行代码。
控制台日志版本
我在bootbox模式中有以下代码行:
echo "<form method='POST'><input type='text' size='10' name='calendar_id' value='".$calendar_id_get."' readonly style='display: none' required/><table class='table table-bordered'><tr><td width='20%'><b>Title</b></td><td width='80%'><input type='text' class='form-control' name='txttitle2' value='".$events['title']."' required/></td></tr><tr><td width='150px'><b>Detail</b></td><td width='250px'><textarea required class='form-control' name='txtdetail2'>".$events['detail']."</textarea></td></tr><tr><td colspan='2' align='center'><input type='submit' class='btn btn-primary btn-lg btn-block' name='edit' value='Save Changes'></td></tr></table></form>";
我的问题是详细信息来自文本区域,如果该文本区域有两行,我的代码看起来像这样(例如,我的详细信息有&#39; 123&#39;第一行和&#39; 456&#39;第二行):
bootbox.alert("<hr><a class='btn btn-info btn-lg btn-block' href='/calendar/index.php?month=03&day=17&year=2015&v=true&f=true'>Add Event</a><hr><br><div class='panel-body'><table class='table table-bordered'><tr><td width='20%'><b>Title:</b></td><td>aw</td></tr><tr><td><b>Detail:<b></td><td>123
456<br /><br /><h6><b>Created By:</b> qwerty | <b>Created On:</b> March 8, 2015, 9:36 pm</h6></td></tr><tr ><td colspan='2'><a class='btn btn-warning btn-lg btn-block' href='/calendar/index.php?month=03&day=17&year=2015&v=true&j=true'>Edit Event</a><br><form method='POST'><input type='text' size='10' name='calendar_id' value='168' readonly style='display: none'/></th><input type='submit' class='btn btn-danger btn-lg btn-block' value='Delete event' name='delete' /></form></td></tr></table></div><hr>");
并在我的控制台上给出了这个错误&#34; Uncaught SyntaxError:Unexpected token ILLEGAL&#34;
可读版本
这是原始代码行:
echo "<form method='POST'><input type='text' size='10' name='calendar_id'
value='".$calendar_id_get."' readonly style='display: none' required/>
<table class='table table-bordered'><tr><td width='20%'><b>Title</b></td>
<td width='80%'><input type='text' class='form-control' name='txttitle2'
value='".$events['title']."' required/></td></tr><tr><td width='150px'><b>Detail</b>
</td><td width='250px'><textarea required class='form-control'
name='txtdetail2'>".$events['detail']."</textarea></td></tr><tr><td colspan='2'
align='center'><input type='submit' class='btn btn-primary btn-lg btn-block' name='edit'
value='Save Changes'></td></tr></table></form>";
如果第一行的详细信息包含123
,第二行包含456
(因为它是textarea),这是输出
这是第一行:
bootbox.alert("<hr><a class='btn btn-info btn-lg btn-block'
href='/calendar/index.php?month=03&day=17&year=2015&v=true&f=true'>Add Event</a><hr><br>
<div class='panel-body'><table class='table table-bordered'><tr><td width='20%'>
<b>Title:</b></td><td>aw</td></tr><tr><td><b>Detail:<b></td><td>123
这是第二行:
456<br /><br /><h6><b>Created By:</b> qwerty | <b>Created On:</b> March 8, 2015, 9:36
pm</h6></td></tr><tr ><td colspan='2'><a class='btn btn-warning btn-lg btn-block'
href='/calendar/index.php?month=03&day=17&year=2015&v=true&j=true'>Edit Event</a><br>
<form method='POST'><input type='text' size='10' name='calendar_id' value='168'
readonly style='display: none'/></th><input type='submit' class='btn btn-danger btn-lg
btn-block' value='Delete event' name='delete' /></form></td></tr></table></div><hr>");