【问题标题】:How to throw a server side error message in thickbox using php如何使用php在thickbox中抛出服务器端错误消息
【发布时间】:2010-05-07 09:42:59
【问题描述】:

我的问题简介:

我正在使用 php 验证服务器端的注册表单,并且工作正常。

现在我的问题是我需要使用弹出窗口之类的厚框显示错误消息。

这可能吗。如果是,请解释如何?

提前致谢

代码:

<script type="text/javascript" src="thickbox/jquery-latest.js"></script>
<script type="text/javascript" src="thickbox/thickbox.js"></script>
<link href="thickbox/thickbox.css" rel="stylesheet" type="text/css" />



<span class="prtexterror" style="color:#FF0000;display:none;" id="hiddenModalContent" >{$error_login}</span>


{literal}
<script language="javascript" type="text/javascript">



  $(document).ready(function() {
    tb_show("Please, login", "?tb_inline=true&inlineId=hiddenModalContent&height=180&width=300&modal=true", null);
});



</script>
{/literal}

【问题讨论】:

  • 您能发布您的代码吗?
  • @Shiki:此代码加载弹出窗口但不加载错误消息

标签: php smarty thickbox


【解决方案1】:

我浏览了 Thinkbox 的文档。看来您必须将错误消息放在带有 id 的 div 上:

<div id="errorMessage">
{$errorMessage}
</div>

然后,您的脚本应提供要在 inlineId 参数中显示的 div 的 ID:

tb_show("HAI","#TB_inline? height=240&amp;width=405&amp;inlineId=errorMessage&amp;modal=true",null);

【讨论】:

  • 仍然 id 在弹出窗口中没有得到任何东西。任何其他方式
【解决方案2】:

好的,我已经快速浏览了Thickbox Documentation and Examples,特别是我认为您正在使用它作为创建此功能的框架的那个。

文档中没有很好的解释,但是 href 中提到的“hiddenModalContent”实际上是指包含要显示的文本的 DIV 元素在弹出的Thickbox中。因此,如果您没有 ID 为“hiddenModalContent”的元素,这可以解释为什么您会收到一个空的弹出窗口。

解决方案?替换:

<a href="#TB_inline?height=240&amp;width=405&amp;inlineId=hiddenModalContent&amp;modal=true" class="thickbox">{$errorMessage}</a>

与:

<div id="hiddenModalContent" style="display:none;">{$errorMessage}</div>

然后,当$(document).ready(...执行时,该DIV的内容将作为Thickbox的内容。

【讨论】:

  • 我还没有在弹出窗口中得到任何东西。任何其他方式
  • 我在这里描述的是Thickbox文档所建议的如何使用它自己。本质是页面中必须有一个元素包含您要显示的消息,并且对Thickbox的调用必须将该元素的ID作为“inlineId”值。这是唯一可行的方法。 $errorMessage 变量实际上是否返回任何内容?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-03
  • 1970-01-01
  • 2019-04-03
  • 2017-05-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多