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

时间:2018-08-23 10:55:01

标签: javascript php css html5 codeigniter

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

//所以所有从打开到关闭之间的按钮都与form_open链接

3 个答案:

答案 0 :(得分:0)

请检查以下代码,它可以正常工作。

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

答案 1 :(得分:0)

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

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

答案 2 :(得分:0)

我弄清楚为什么会这样... 这是由于按钮标记位于form_open标记和form_close标记之间,因为我将按钮标记更改为div而不是正常工作。 因此可以得出结论,当您提交表单时,请勿使用任何类型的按钮标签,而只能使用div标签,span标签等。