基础表单生成器

表单分为三部分,分别有三个文件组成,“index.php”,“fountion.php”,“data.php”

data.php是数组文件

<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/3/25
 * Time: 11:03
 */

$data = [
    [
        "text" =>"姓     名:",
        "tag" =>"input",
        "attr" =>['type'=>'text','name'=>'username']
    ],
    [
        "text" =>"密     名:",
        "tag" =>"input",
        "attr" =>['type'=>'password','name'=>'pwd']
    ],
    [
        "text" =>"邮     箱:",
        "tag" =>"input",
        "attr" =>['type'=>'text','name'=>'email']
    ],
    [
        "text" =>"电     话:",
        "tag" =>"input",
        "attr" =>['type'=>'text','name'=>'tel']
    ],
    [
        'tag' => 'input',
        'text' => '性  别:',
            'attr' => ['type' => 'radio', 'name' => 'gender'],
            'option' => ['m' => '男', 'w' => '女']
    ],
    [
        'tag' => 'checkbox',
        'text' => '爱  好:',
        'attr' => ['type' => 'checkbox', 'name' => 'box'],
        'option' => ['m' => '游泳', 'n' => '打游戏','v' => '生活', 'c' => '跑步']
    ],
    [
        'tag' => 'select',
        'text' => '住  址:',
        'attr' => ['name' => 'area'],
        'option' => ['' => '--请选择--', 'BJ' => '北京', 'SH' => '上海', 'SZ' => '深圳',]
    ],
    [
        'tag' => 'textarea',
        'text' => '自我介绍:',
        'attr' => ['name' => 'declare', 'cols' => '50', 'rows' => '5']
    ]
];


fountion.php文件是函数文件

<?php
include "data.php";
//引入文件
function generate(){
    //定义综合函数
    $html="";
    global  $data;
//声明全局变量
    foreach ($data as $item){
        //循环遍历 $item

        if ($item["tag"]=="input"){
//如果
            $html=$html.input_html($item);
        }else if ($item["tag"]=="select"){
            $html=$html.select_html($item);
        }else if ($item["tag"]=="textarea"){
            $html=$html.textarea_html($item);
        }/*else if ($item["tag"]=="checkbox"){
            $html=$html.checkbox_html($item);
        }*/
    }
return $html."<p></p>";
}
function input_html($item){
    $html="";
    if ($item["attr"]["type"]=="text"){
$html=$item["text"]."<input type='{$item['attr']['type']}'name='{$item['attr']['name']}'>";
    }else if ($item["attr"]["type"]=="radio"){
$html=$item["text"];
$html=$html."<input type= '{$item['attr']['type']}' name='a' value='{$item['option']['w']}'>男";
$html=$html."<input type= '{$item['attr']['type']}' name='a' value='{$item['option']['m']}'>女";
    }
    return $html."<p></p>";
}
//下拉列表
function select_html($item){
    $html=$item['text'];
    $html=$html."<select>";
    foreach ($item["option"] as $v){
        $html.="<option value='$v'>$v</option>";
    }
    $html=$html."</select>";

return $html."<p></p>";

}
//多行文本框
function textarea_html($item){
    $html="";
    if ($item["attr"]["name"]=="declare"){
        $html=$item["text"]."<textarea name={$item['attr']['name']}></textarea >";
    }
return $html;
}

//复选框


?>

data.php文件是函数文件

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<form action="">
    <?php include "function.php" ;

    echo generate();
    ?>
</form>
</body>
</html>

以上就是表单的内容了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
QForm是什么? QForm是一套基于数据库的电子表格平台,QForm是一套基于WEB的数据库表单快速制作平台,QForm是一套强大的二次开发平台。 QForm有些什么特点? 1、QForm上设计表单不需要编写代码,通过简单的拖拉和配置即可制作出各种数库表单,如生产质量验验、客户订单、入库出库单、合同、会议记录、各种统计分析报表……。 2、QForm为制作业务表单提供了大量的常规业务逻辑,如强制输入、强制输入、默认值、文本长度、文本类型、小数位数、负数红字、表单间调用、依据流程设定某些区域是否可用……,只需过简单的配置就可以完成这些功能。 3、QForm具备强大的文档和电子表格制作能力,可以勾画出类似Word或Excel文档的表单,与Word和Excel不同的是QForm表单读写或统计的数据来源于数据库。QForm目前支持112个表格函数,这些函数大部分保持了与Excel函数的一致性。 4、QForm内部采用XML+HTML+TCP/IP与数据库交互数据,确保QForm可以在同一表单内,读写分布在不同区域(如不同城市)或不同系统(如ERP、CRM等)的数据,实现数据集成,消除信息孤岛,轻松撑控企业各种信息。 5、QForm允许我们编写各种SQL语句和VBScript或Jscript。此外,QForm制作的表单可以脱离QForm客户端框架供第三方系统调用, 也允许我们在QForm表单上调用的第三方组件。 6、QForm通常由实际业务人员快速勾画适合本部门需求的业务表单,消除对开发人员或软件公司的依赖和沟通障碍,并且结果表单柔韧性强,根据业务变更及时调整,从而大大降低成本和风险。 总之QForm具备快速、简单、经济、灵活、数据异构等特点,使得我们可以在低成本,低风险的情况下,轻松架构和撑控高质量的信息系统。 联系QForm:qform@163.com,13711407657。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值