繁体   English   中英

在codeigniter中,我通过form_open提交表单,所有按钮都由我的form_open('Home / page')链接

[英]In codeigniter i submit a form by form_open there all button linked by my form_open('Home/page')

 <?php echo form_open('Home/OtherDetail'); ?> <div class="row" style="margin-bottom:5%;" > <div class="col col-lg-4 col-md-12 col-sm-12 col-xs-12" style="font-weight: 600; font-size: 100%;">Name:</div> <div class="col col-lg-8 col-md-12 col-sm-12 col-xs-12"><input type="text" name="name" style="width:100%" value=""></div> </div> <div class="row" style="margin-bottom:5%;"> <div class="col col-lg-4 col-md-12 col-sm-12 col-xs-12" style="font-weight: 600;font-size: 100%;">Father Full Name:</div> <div class="col col-lg-8 col-md-12 col-sm-12 col-xs-12"><input type="text" name="FatherName" style="width:100%" value=""></div> </div> <div class="row" style="margin-bottom:5%;"> <div class="col col-lg-4 col-md-12 col-sm-12 col-xs-12" style="font-weight: 600;font-size: 100%;">Address:</div> <div class="col col-lg-8 col-md-12 col-sm-12 col-xs-12"><input type="text" name="Address" style="width:100%" value=""></div> </div> <a href="Home/new"><button >add</button></a> <a href="Home/new"><button >negative</button></a> <?php form_submit('name',value); ?> //so all button which are comes in between from open and form close linked with form_open <?php form_close(); ?> 

//因此所有从open和form close之间出现的按钮都与form_open链接

请检查以下代码,它可以完美工作。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Simple CodeIgniter App - Todos</title>
    <link rel="stylesheet"
    href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
</head>
<body>
    <?php echo form_open('Home/OtherDetail'); ?>
        <div class="row" style="margin-bottom:5%;" >
            <div class="col col-lg-4 col-md-12 col-sm-12 col-xs-12" style="font-weight: 600; font-size: 100%;">Name:</div>
            <div class="col col-lg-8 col-md-12 col-sm-12 col-xs-12"><input type="text" name="name" style="width:100%" value=""></div> 
        </div>

        <div class="row" style="margin-bottom:5%;">
            <div class="col col-lg-4 col-md-12 col-sm-12 col-xs-12" style="font-weight: 600;font-size: 100%;">Father Full Name:</div>
            <div class="col col-lg-8 col-md-12 col-sm-12 col-xs-12"><input type="text" name="FatherName" style="width:100%" value=""></div>
        </div>

        <div class="row" style="margin-bottom:5%;">
            <div class="col col-lg-4 col-md-12 col-sm-12 col-xs-12" style="font-weight: 600;font-size: 100%;">Address:</div>
            <div class="col col-lg-8 col-md-12 col-sm-12 col-xs-12"><input type="text" name="Address" style="width:100%" value=""></div>
        </div>

        <a href="Home/new">
            <?php echo form_button('add','add'); ?>
            <!-- <button type>add</button> -->
        </a>
        <a href="Home/new">
            <?php echo form_button('negative','negative'); ?>
            <!-- <button type>negative</button> -->
        </a>
        <?php echo form_submit('name','btn_name'); ?>//so all button which are comes in between from open and form close linked with form_open
    <?php echo form_close(); ?>
</body>
</html>

如果您不希望HTML BUTTON像Submit那样起作用,则需要添加标记type =“ button”。

<form>
    <button>This button submit</button>
    <button type="button">This button DO NOT submit</button>
    <!-- Default attribute type value is "submit" -->
</form>

我弄清楚为什么会这样...那是由于按钮标记位于form_open标记和form_close标记之间,因为我将按钮标记更改为div而不是正常工作....所以有结论您提交的表格永远不要使用任何按钮标签,而只能使用div标签,span标签等。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM