AJAX__showmessage()函数配合AJAX弹窗
discuz定义的函数showmessage()可以将弹窗以AJAX的方式弹出,首先要将模板文件中的表单按照格式编写按照格式编写.下面以"积分转帐"页面介绍
模板文件
[html]
<!--{elseif $_G['gp_op'] == 'transfer'}-->
<!--{if $_G[setting][transferstatus] && $_G['group']['allowtransfer']}-->
<form id="transferform" name="transferform" method="post" autocomplete="off" action="home.php?mod=spacecp&ac=credit&op=transfer" onsubmit="ajaxpost(this.id, 'return_transfercredit');">
<input type="hidden" name="formhash" value="{FORMHASH}" />
<input type="hidden" name="transfersubmit" value="true" />
<input type="hidden" name="handlekey" value="transfercredit" />
<table cellspacing="0" cellpadding="0" class="tfm mtn">
<tr>
<th>{lang memcp_credits_transfer}</th>
<td class="pns">
<input type="text" name="transferamount" id="transferamount" class="px" size="5" style="width: auto;" value="0" />
{$_G[setting][extcredits][$_G[setting][creditstran易做图tra][9]][title]}
{lang credits_give}
<input type="text" name="to" id="to" class="px" size="15" style="width: auto;" />
</td>
<td width="300" class="d">
{lang memcp_credits_transfer_min_balance} $_G[setting][transfermincredits] {$_G[setting][extcredits][$_G[setting][creditstran易做图tra][9]][unit]}<br />
<!--{if intval($taxpercent) > 0}-->{lang credits_tax} $taxpercent<!--{/if}-->
</td>
</tr>
<tr>
<th><span class="rq">*</span>{lang transfer_login_password}</th>
<td><input type="password" name="password" class="px" value="" /></td>
</tr>
<tr>
<th>{lang credits_transfer_message}</th>
<td><input type="text" name="transfermessage" class="px" size="40" /></td>
</tr>
<tr>
<th> </th>
<td colspan="2">
<button type="submit" name="transfersubmit_btn" id="transfersubmit_btn" class="pn" value="true"><em>{lang memcp_credits_transfer}</em></button>
<span style="display: none" id="return_transfercredit"></span>
</td>
</tr>
</table>
</form>
<!--{/if}-->
其中的HTML:
[html]
<form id="transferform" name="transferform" method="post" autocomplete="off" action="home.php?mod=spacecp&ac=credit&op=transfer" onsubmit="ajaxpost(this.id, 'return_transfercredit');">
onsubmit=ajaxpost(this.id,'return_transfercredit')是以ajaxpost方式提交,this.id是本表单id,return_transfercredit为返回信息标签ID,就是<span style="display:none" id="return_transfercredit"></span>
其中的HTML:
[html]
<input type="hidden" name="handlekey" value="transfercredit" />
name="handlekey",name值不能修改其它值;value值为return_xxx中的xxx,disucz中的showmessage()会依据$_G['gp_handlekey']做一些处理
程序文件如下:
[php]
elseif ($_G['gp_op'] == 'transfer') {
if(!($_G['setting']['transferstatus'] && $_G['group']['allowtransfer'])) {
showmessage('action_closed', NULL);
}
补充:Web开发 , 其他 ,