简体   繁体   中英

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(); ?> 

//so all button which are comes in between from open and form close linked with form_open

Please check the below code and it works perfect.

<!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>

If you do not want that HTML BUTTON act like Submit, you need to add the tag 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标签等。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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