Welcome Guest, Not a member yet? Register   Sign In
Multiple form_open with button
#1

Hello,
I have several buttons which should make different things.
To one, a button should make one entry in table 1 and another in table 2.
But if I do it as in the code below.
He always makes an entry in Table 1.

How can I assign the respective buttons?


PHP Code:
<?php echo form_open('Karte/insert_artikel'); ?>
<?php 
echo form_open('Karte/insert_trade'); ?>
                            <input type="hidden" name="add_karte_id" value="<?php echo $edition_views['tb_karte_id']; ?>">
                            <input type="hidden" name="add_karten_stats_id" value="<?php echo $edition_views['tb_karte_karten_stats']; ?>">
                            <input type="hidden" name="add_karte_sprache" value="<?php echo $edition_views['tb_sprache_id']; ?>">
                            <input type="hidden" name="add_karte_qualitat" value="<?php echo $edition_views['tb_qualitat_id']; ?>">
                            <input type="hidden" name="add_karte_auflage" value="<?php echo $edition_views['tb_auflage_id']; ?>">
                            <input type="hidden" name="add_karte_edition_stats" value="<?php echo $edition_views['tb_karte_edition_stats']; ?>">
                            <input type="hidden" name="add_karte_datum" value="<?php $date date_create($edition_views['tb_karte_datum']); echo date_format($date,"Y-m-d H:i:s");?>">
                            <tr>
                                <td><a href="#" data-toggle="tooltip" title="<?php echo $edition_views['tb_edition_name']; ?>"><?php echo $edition_views['tb_edition_kurzel']; ?>-<?php echo $edition_views['tb_sprache_kurzel']; ?><?php echo $edition_views['tb_edition_stats_nummer']; ?></a></td>
                                <td><button class="btn btn-default" data-toggle="tooltip" data-placement="top" title="<?php echo $edition_views['tb_qualitat_name']; ?>"><img src="<?php echo base_url(); ?>assets/images/site/qualitat/<?php echo $edition_views['tb_qualitat_id']; ?>.png"/>&nbsp;<?php echo $edition_views['tb_qualitat_short']; ?></button></td>
                                <td><button class="btn btn-default" data-toggle="tooltip" data-placement="top" title="<?php echo $edition_views['tb_rare_name']; ?>"><?php echo $edition_views['tb_rare_short']; ?></button></td>
                                <td><?php echo $edition_views['tb_auflage_name_de']; ?></td>
                                <td><?php $date date_create($edition_views['tb_karte_datum']); echo date_format($date,"d.m.Y");?></td>
                                <td><?php echo str_pad($edition_views['tb_karte_anzahl'], 2'0'STR_PAD_LEFT); ?></td>
                                <td>
<?php
    
switch($edition_views['tb_karte_versuche'])
        {
            case (
0):
            echo 
"<FONT COLOR='#000000'>".$edition_views['tb_karte_versuche']."</FONT>";
            break;

            case (
1):
            echo 
"<strong><FONT COLOR='#D7DF01'>".$edition_views['tb_karte_versuche']."</FONT></strong>";
            break;

            case (
2):
            echo 
"<strong><FONT COLOR='#298A08'>".$edition_views['tb_karte_versuche']."</FONT></strong>";
            break;

            case (
3):
            echo 
"<strong><FONT COLOR='#DF0101'>".$edition_views['tb_karte_versuche']."</FONT></strong>";
            break;
        }
?>
                                </td>
                                <td>
                                    <div class="input-group">
                                        <span class="input-group-btn">
                                            <button type="button" class="btn btn-default btn-number" disabled="disabled" data-type="minus" data-field="add_karte_menge[<?php echo $edition_views['tb_karte_id']; ?>]"><span class="glyphicon glyphicon-minus"></span></button>
                                        </span>
                                        <input type="text" name="add_karte_menge[<?php echo $edition_views['tb_karte_id']; ?>]" class="form-control input-number" value="1" min="1" max="<?php echo $edition_views['tb_karte_anzahl']; ?>">
                                        <span class="input-group-btn">
                                            <button type="button" class="btn btn-default btn-number" data-type="plus" data-field="add_karte_menge[<?php echo $edition_views['tb_karte_id']; ?>]"><span class="glyphicon glyphicon-plus"></span></button>
                                            <button type="submit" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="Verkauf Hinzufügen"><span class="glyphicon glyphicon-shopping-cart" aria-hidden="true"></span></button>
                                            <button type="submit" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="Tausch Hinzufügen"><span class="glyphicon glyphicon-transfer" aria-hidden="true"></span></button>
                                            <button type="submit" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="Zur Sammlung"><span class="glyphicon glyphicon-gift" aria-hidden="true"></span></button>
                                            <button type="submit" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="Bearbeiten"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></button>
                                            <button type="submit" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="Verloren"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></button>
                                        </span>
                                    </div>
                                </td>
                            </tr>
<?php echo form_close(); ?>
<?php 
echo form_close(); ?>
Reply
#2

(10-05-2017, 05:39 AM)Germanikus Wrote: Hello,
I have several buttons which should make different things.
To one, a button should make one entry in table 1 and another in table 2.
But if I do it as in the code below.
He always makes an entry in Table 1.

How can I assign the respective buttons?


PHP Code:
<?php echo form_open('Karte/insert_artikel'); ?>
<?php 
echo form_open('Karte/insert_trade'); ?>
 <input type="hidden" name="add_karte_id" value="<?php echo $edition_views['tb_karte_id']; ?>">
 <input type="hidden" name="add_karten_stats_id" value="<?php echo $edition_views['tb_karte_karten_stats']; ?>">
 <input type="hidden" name="add_karte_sprache" value="<?php echo $edition_views['tb_sprache_id']; ?>">
 <input type="hidden" name="add_karte_qualitat" value="<?php echo $edition_views['tb_qualitat_id']; ?>">
 <input type="hidden" name="add_karte_auflage" value="<?php echo $edition_views['tb_auflage_id']; ?>">
 <input type="hidden" name="add_karte_edition_stats" value="<?php echo $edition_views['tb_karte_edition_stats']; ?>">
 <input type="hidden" name="add_karte_datum" value="<?php $date date_create($edition_views['tb_karte_datum']); echo date_format($date,"Y-m-d H:i:s");?>">
 <tr>
 <td><a href="#" data-toggle="tooltip" title="<?php echo $edition_views['tb_edition_name']; ?>"><?php echo $edition_views['tb_edition_kurzel']; ?>-<?php echo $edition_views['tb_sprache_kurzel']; ?><?php echo $edition_views['tb_edition_stats_nummer']; ?></a></td>
 <td><button class="btn btn-default" data-toggle="tooltip" data-placement="top" title="<?php echo $edition_views['tb_qualitat_name']; ?>"><img src="<?php echo base_url(); ?>assets/images/site/qualitat/<?php echo $edition_views['tb_qualitat_id']; ?>.png"/>&nbsp;<?php echo $edition_views['tb_qualitat_short']; ?></button></td>
 <td><button class="btn btn-default" data-toggle="tooltip" data-placement="top" title="<?php echo $edition_views['tb_rare_name']; ?>"><?php echo $edition_views['tb_rare_short']; ?></button></td>
 <td><?php echo $edition_views['tb_auflage_name_de']; ?></td>
 <td><?php $date date_create($edition_views['tb_karte_datum']); echo date_format($date,"d.m.Y");?></td>
 <td><?php echo str_pad($edition_views['tb_karte_anzahl'], 2'0'STR_PAD_LEFT); ?></td>
 <td>
<?php
 
switch($edition_views['tb_karte_versuche'])
 {
 case (
0):
 echo 
"<FONT COLOR='#000000'>".$edition_views['tb_karte_versuche']."</FONT>";
 break;

 case (
1):
 echo 
"<strong><FONT COLOR='#D7DF01'>".$edition_views['tb_karte_versuche']."</FONT></strong>";
 break;

 case (
2):
 echo 
"<strong><FONT COLOR='#298A08'>".$edition_views['tb_karte_versuche']."</FONT></strong>";
 break;

 case (
3):
 echo 
"<strong><FONT COLOR='#DF0101'>".$edition_views['tb_karte_versuche']."</FONT></strong>";
 break;
 }
?>
 </td>
 <td>
 <div class="input-group">
 <span class="input-group-btn">
 <button type="button" class="btn btn-default btn-number" disabled="disabled" data-type="minus" data-field="add_karte_menge[<?php echo $edition_views['tb_karte_id']; ?>]"><span class="glyphicon glyphicon-minus"></span></button>
 </span>
 <input type="text" name="add_karte_menge[<?php echo $edition_views['tb_karte_id']; ?>]" class="form-control input-number" value="1" min="1" max="<?php echo $edition_views['tb_karte_anzahl']; ?>">
 <span class="input-group-btn">
 <button type="button" class="btn btn-default btn-number" data-type="plus" data-field="add_karte_menge[<?php echo $edition_views['tb_karte_id']; ?>]"><span class="glyphicon glyphicon-plus"></span></button>
 <button type="submit" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="Verkauf Hinzufügen"><span class="glyphicon glyphicon-shopping-cart" aria-hidden="true"></span></button>
 <button type="submit" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="Tausch Hinzufügen"><span class="glyphicon glyphicon-transfer" aria-hidden="true"></span></button>
 <button type="submit" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="Zur Sammlung"><span class="glyphicon glyphicon-gift" aria-hidden="true"></span></button>
 <button type="submit" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="Bearbeiten"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></button>
 <button type="submit" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="Verloren"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></button>
 </span>
 </div>
 </td>
 </tr>
<?php echo form_close(); ?>
<?php 
echo form_close(); ?>

1. form in a form does not work.

2.
Code:
<?php
   switch($edition_views['tb_karte_versuche'])
       {
           case (0):
           echo "<FONT COLOR='#000000'>".$edition_views['tb_karte_versuche']."</FONT>";
           break;

           case (1):
           echo "<strong><FONT COLOR='#D7DF01'>".$edition_views['tb_karte_versuche']."</FONT></strong>";
           break;

           case (2):
           echo "<strong><FONT COLOR='#298A08'>".$edition_views['tb_karte_versuche']."</FONT></strong>";
           break;

           case (3):
           echo "<strong><FONT COLOR='#DF0101'>".$edition_views['tb_karte_versuche']."</FONT></strong>";
           break;
       }
?>

use css style + class e.g.

Code:
.tb_karte_versuche_1 {
   color: #xxxxxx;
}

in you template

Code:
<span class="tb_karte_versuche_<?=$edition_views['tb_karte_versuche']?>"><?=$edition_views['tb_karte_versuche']?></span>

3.
https://www.codeigniter.com/user_guide/h...orm_hidden
Reply
#3

look weird in the way you have form nested within the form. I would seperate them out by div and let each form has its id such as
<form id='form1'> and <form id='form2'>.  Each submit action then can always bind to its own action such as

Code:
$('#form1).submit(function(e){
   e.preventDefault();
   var data_sub1= $(this).serialize(); //all your submitted data here in json
    var url ='/SomeController/action';
   $.post(url,data_sub1,function(datacb){
      //your action here with callback
       console.log('such as ' + JSON.stringify(datacb));
   },'json');
});
//similar  code for form2
Reply




Theme © iAndrew 2016 - Forum software by © MyBB