成都创新互联网站制作重庆分公司

如何使用xajax的FORM函数-创新互联

本篇内容介绍了“如何使用xajax的FORM函数”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

10年积累的网站建设、做网站经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计制作后付款的网站建设流程,更有罗甸免费网站建设让你可以放心的选择与我们合作。

代码如下:

// signup.php
// demonstrates a simple multipage form using xajax
// and the xajax.getFormValues() function.
// using xajax version 0.1 beta4
// http://xajax.sourceforge.net
session_start();
include ("xajax.inc.php");
function processForm($aFormValues)
{
        if (array_key_exists("username",$aFormValues))
        {
                return processAccountData($aFormValues);
        }
        else if (array_key_exists("firstName",$aFormValues))
        {
                return processPersonalData($aFormValues);
        }
}
function processAccountData($aFormValues)
{
        $objResponse = new xajaxResponse();
        $bError = false;
        if (trim($aFormValues['username']) == "")
        {
                $objResponse->addAlert("Please enter a username.");
                $bError = true;
        }
        if (trim($aFormValues['newPass1']) == "")
        {
                $objResponse->addAlert("You may not have a blank password.");
                $bError = true;
        }
        if ($aFormValues['newPass1'] != $aFormValues['newPass2'])
        {
                $objResponse->addAlert("Passwords do not match.  Try again.");
                $bError = true;
        }
        if (!$bError)
        {
                $_SESSION = array();
                $_SESSION['newaccount']['username'] = trim($aFormValues['username']);
                $_SESSION['newaccount']['password'] = trim($aFormValues['newPass1']);
                $sForm = "

";
                $sForm .="
First Name:
";
                $sForm .="
Last Name:
";
                $sForm .="
Email:
";
                $sForm .="
";
                $sForm .="
";
                $objResponse->addAssign("formDiv","innerHTML",$sForm);
                $objResponse->addAssign("formWrapper","style.backgroundColor", "rgb(67,149,97)");
                $objResponse->addAssign("outputDiv","innerHTML","\$_SESSION:
".var_export($_SESSION,true)."
");
        }
        else
        {
                $objResponse->addAssign("submitButton","value","continue ->");
                $objResponse->addAssign("submitButton","disabled",false);
        }
        return $objResponse->getXML();
}
function processPersonalData($aFormValues)
{
        $objResponse = new xajaxResponse();
        $bError = false;
        if (trim($aFormValues['firstName']) == "")
        {
                $objResponse->addAlert("Please enter your first name.");
                $bError = true;
        }
        if (trim($aFormValues['lastName']) == "")
        {
                $objResponse->addAlert("Please enter your last name.");
                $bError = true;
        }
        if (!eregi("^[a-zA-Z0-9]+[_a-zA-Z0-9-]*(\.[_a-z0-9-]+)*@[a-z??????0-9]+(-[a-z??????0-9]+)*(\.[a-z??????0-9-]+)*(\.[a-z]{2,4})$", $aFormValues['email']))
        {
                $objResponse->addAlert("Please enter a valid email address.");
                $bError = true;
        }
        if (!$bError)
        {
                $_SESSION['newaccount']['firstname'] = $aFormValues['firstName'];
                $_SESSION['newaccount']['lastname'] = $aFormValues['lastName'];
                $_SESSION['newaccount']['email'] = $aFormValues['email'];
                $objResponse->addAssign("formDiv","style.textAlign","center");
                $sForm = "Account created.
Thank you.";
                $objResponse->addAssign("formDiv","innerHTML",$sForm);
                $objResponse->addAssign("formWrapper","style.backgroundColor", "rgb(67,97,149)");
                $objResponse->addAssign("outputDiv","innerHTML","\$_SESSION:
".var_export($_SESSION,true)."
");
        }
        else
        {
                $objResponse->addAssign("submitButton","value","done");
                $objResponse->addAssign("submitButton","disabled",false);
        }
        return $objResponse->getXML();
}
$xajax = new xajax();
//$xajax->debugOn();
$xajax->registerFunction("processForm");
$xajax->processRequests();
?>

                printJavascript(); ?>
               
               
       
       
               

                       
Create a New Account

                       

                               

                                       
Username:

                                       
Password:

                                       
Confirm Password:

                                       

                               

                       

               

               

               

       



“如何使用xajax的FORM函数”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联网站,小编将为大家输出更多高质量的实用文章!


新闻标题:如何使用xajax的FORM函数-创新互联
文章链接:http://cxhlcq.com/article/eddce.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部