How to make dynamic bootstrap modal work on Iphones? - php

There is problem in opening bootstrap modal in iphones.
If i use static modal like below,
<a href="#responsive" data-toggle="modal"><button class="btn btn-green ">Add Product<i class="fa fa-plus"></i></button>
</a>
<!-- start: BOOTSTRAP EXTENDED MODALS -->
<div id="responsive" class="modal extended-modal fade no-display">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
×
</button>
<h4 class="modal-title" style="color:red">Add New Product</h4>
</div>
<div class="modal-body">
<div class="row">
<form name="new" action="<?php echo base_url() ?>admin/addProduct" method="post" enctype="multipart/form-data" autocomplete="off">
<div class="col-md-6">
<h4><b>Category Name <span class="symbol required"></span></b></h4>
<p>
<select class="form-control" name="cat_id" required>
<option value="">---- Select Category ----</option>
<?php foreach($cat['list'] as $rows=>$value){ ?>
<option value="<?php echo $cat['list'][$rows]->cat_id; ?>"><?php echo ucwords($cat['list'][$rows]->cat_name); ?></option>
<?php } ?>
</select>
</p>
</div>
<div class="col-md-6">
<h4><b>Product Name <span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="text" name="item_name" required>
</p>
</div>
<div class="col-md-6">
<h4><b>Small Description <span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="text" name="small_desc">
</p>
</div>
<div class="col-md-6">
<h4><b>Quantity<span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="number" name="quantity" required min="1">
</p>
</div>
<div class="col-md-6">
<h4><b>Customer Price<span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="number" name="price" required min="1">
</p>
</div>
<div class="col-md-6">
<h4><b>Reseller Price<span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="number" name="reseller" required min="1">
</p>
</div>
<div class="col-md-6">
<h4><b>Color<span class="symbol "></span></b></h4>
<p>
<input class="form-control" type="text" name="color">
</p>
</div>
<div class="col-md-6">
<h4><b>Availability <span class="symbol required"></span></b></h4>
<select class="form-control" name="availability">
<option value="1">Available</option>
<option value="0">Not Available</option>
</select>
</div>
<div class="col-md-6">
<h4><b>Image <span class="symbol required"></span></b></h4>
<p>
<input class="form-control" accept="image/*" onchange="loadFile(event)" type="file" name="userfile" required multiple>
<img id="output" width="100px" height="100px" />
</p>
</div>
</div>
</div>
<div class="modal-footer">
<button type="reset" data-dismiss="modal" class="btn btn-light-grey">
Close
</button>
<button type="submit" class="btn btn-blue">
Add Product
</button>
</div>
</form>
</div>
</div>
</div>
<!-- End Modal -->
the modal will open properly and i can enter values.
But if use the modal for editing like below,
<a href="#edit<?php echo $product['list'][$row]->item_id; ?>" data-toggle="modal">
<button class="btn btn-blue"><i class="fa fa-pencil"></i> Edit </button>
</a>
<div id="edit<?php echo $product['list'][$row]->item_id?>" class="modal extended-modal fade no-display">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
×
</button>
<h4 class="modal-title" style="color:red">Edit Product</h4>
</div>
<div class="modal-body">
<div class="row">
<form action="<?php echo base_url() ?>admin/editProduct" enctype="multipart/form-data" method="post" autocomplete="off">
<div class="col-md-6">
<h4><b>Category Name <span class="symbol required"></span></b></h4>
<p>
<select class="form-control" name="cat_id" required>
<option value="">---- Select Category ----</option>
<?php
foreach($cat['list'] as $rows=>$value){ ?>
<option value="<?php echo $cat['list'][$rows]->cat_id; ?>"<?php if($cat['list'][$rows]->cat_id == $product['list'][$row]->cat_id) echo "selected=selected"; ?>><?php echo ucwords($cat['list'][$rows]->cat_name); ?></option>
<?php } ?>
</select>
</p>
</div>
<div class="col-md-6">
<input type="hidden" name="item_id" value="<?php echo $product['list'][$row]->item_id;?>">
<input type="hidden" name="image_name" value="<?php echo $product['list'][$row]->image;?>">
<h4><b>Product Name <span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="text" name="item_name" value="<?php echo $product['list'][$row]->item_name;?>" required>
</p>
</div>
<div class="col-md-6">
<h4><b>Small Description <span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="text" name="small_desc" value="<?php echo $product['list'][$row]->small_desc;?>">
</p>
</div>
<div class="col-md-6">
<h4><b>Quantity<span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="number" name="quantity" value="<?php echo $product['list'][$row]->quantity;?>" min="1" required>
</p>
</div>
<div class="col-md-6">
<h4><b>Customer Price<span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="text" name="price" value="<?php echo $product['list'][$row]->price;?>" min="1" required>
</p>
</div>
<div class="col-md-6">
<h4><b>Reseller Price<span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="text" name="reseller" value="<?php echo $product['list'][$row]->reseller;?>" min="1" required>
</p>
</div>
<div class="col-md-6">
<h4><b>Color<span class="symbol"></span></b></h4>
<p>
<input class="form-control" type="text" name="color" value="<?php echo $product['list'][$row]->color;?>">
</p>
</div>
<div class="col-md-6">
<h4><b>Availability <span class="symbol required"></span></b></h4>
<select class="form-control" name="availability">
<?php if($product['list'][$row]->availability==1){;?>
<option value="1" selected>Available</option>
<option value="0">Not Available</option>
<?php } else {?>
<option value="1">Available</option>
<option value="0" selected>Not Available</option>
<?php }?>
</select>
</div>
<div class="col-md-6">
<h4><b>Status <span class="symbol required"></span></b></h4>
<select class="form-control" name="status">
<?php if($product['list'][$row]->status==0){;?>
<option value="0" selected>Inactive</option>
<option value="1">Active</option>
<?php } else {?>
<option value="0">Inactive</option>
<option value="1" selected>Active</option>
<?php }?>
</select>
</div>
<div class="col-md-6">
<h4><b>Image <span class=""></span>
</b></h4>
<input class="form-control" type="file" name="userfile">
<img src="<?php echo base_url()." assets/uploads/ ".$product['list'][$row]->image;?>" height="50px" width="50px" border="1px solid #FFF">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn btn-light-grey">
Close
</button>
<button type="submit" class="btn btn-blue">
Update
</button>
</div>
</form>
</div>
</div>
</div>
With dynamic id, the modal will open with light black overlay on it. I can't edit the fields. Nothing is working inside the modal.
I am Not Understanding What is the problem with dynamic modal.
If Anyone knows Please reply.

You can try two things. 1. Move your form tag out and place it like this -
<form action="./admin/editProduct" enctype="multipart/form-data" method="post" autocomplete="off">
<div class="modal-body">
Give your modal z-index of 999 or so using css like this -
<style>
.modal {
z-index: 999;
}
</style>

Related

Boostrap Modal Does not opening when click on edit button

i have been making a crud application using php , mysql and bootstrap. everything is working fine but when i click on edit option the model does not open.i can understand why this is happening.
this is happening when i click on edit button. no modal is showing
Bootstrap modal not showing
code of edit button
<span class="glyphicon glyphicon-edit" style="color: #fff;"></span>
modal code
<div class="modal fade" id="edit<?php echo $row['userid']; ?>" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<center><h4 class="modal-title" id="myModalLabel">Edit</h4></center>
</div>
<div class="modal-body">
<?php
$edit=mysqli_query($conn,"select * from customer_record where userid='".$row['userid']."'");
$erow=mysqli_fetch_array($edit);
?>
<div class="container-fluid">
<form method="POST" action="edit.php?id=<?php echo $erow['userid']; ?>">
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>NAME</label>
<input type="text" name="name" class="form-control" value="<?php echo $erow['name']; ?>">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>PHONE</label>
<input type="text" name="phone" class="form-control" value="<?php echo $erow['phone']; ?>" >
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>PRODUCT</label>
<input type="text" name="product" class="form-control" value="<?php echo $erow['product']; ?>" >
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>CLIENT NAME</label>
<select type="text" name="client" class="form-control" value="<?php echo $erow['client']; ?>">
<option>select</option>
<option> Carrefour FORT - L </option>
<option> Carrefour EMP - L </option>
<option> Carrefour PKJS - L </option>
<option> Carrefour LYPR - F </option>
<option> Carrefour WTC - I</option>
<option> Carrefour PAL - K</option>
<option> Carrefour L.ONE -K</option>
<option> Hyundai </option>
<option> Kenwood </option>
<option> Canon </option>
<option> Cash </option>
<option> Multynet </option>
<option> Panasonic</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label>ADDRESS</label>
<input type="text" name="address" class="form-control" value="<?php echo $erow['address']; ?>">
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label>ZONE AREA</label>
<select name="zone_area" class="form-control" value="<?php echo $erow['zone_area']; ?>">
<option>select</option>
<option>A</option>
<option>B</option>
<option>C</option>
<option>D</option>
<option>E</option>
<option>F</option>
<option>G</option>
<option>H</option>
<option>I</option>
<option>J</option>
<option>NA</option>
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>DELIVERY DATE</label>
<input type="date" name="delivery_date" class="form-control" value="<?php echo $erow['delivery_date']; ?>">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>DELIVERY STATUS</label>
<select name="delivery_status" class="form-control" value="<?php echo $erow['delivery_status']; ?>">
<option>select</option>
<option> Self Carry </option>
<option> Pending </option>
<option> Lift Back</option>
<option> Deliverd</option>
<option> Deliverd in 2nd attempt</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>INVOICE #</label>
<input type="text" name="invoice" class="form-control" value="<?php echo $erow['invoice']; ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>VEHICLE #</label>
<select type="text" name="vehicle" class="form-control" value="<?php echo $erow['vehicle']; ?>">
<option>select</option>
<option> RIN - 4546 </option>
<option> LES - 2200 </option>
<option> LES - 8732 </option>
<option> LES - 5884 </option>
<option> LES - 4964 </option>
<option> LES - 2150 </option>
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>COUPAN #</label>
<input type="text" name="coupan" class="form-control" value="<?php echo $erow['coupan']; ?>">
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>INSTALLER NAME</label>
<input type="text" name="installername" class="form-control" value="<?php echo $erow['installername']; ?>">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>Installation Date</label>
<input type="date" name="installationdate" class="form-control" value="<?php echo $erow['installationdate']; ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>INSTALLATION STATUS</label>
<select name="installationstatus" class="form-control" value="<?php echo $erow['installationstatus']; ?>">
<option>select</option>
<option>PROCESSED</option>
<option>COMPLETED</option>
<option>FAILED</option>
<option>Installed in 2nd Attempt</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Remarks ( Delivery + installation )</label>
<input type="text" id="remarks" name="remarks" class="form-control" value="<?php echo $erow['remarks']; ?>">
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
<button type="submit" class="btn btn-warning"><span class="glyphicon glyphicon-check"></span> Save</button>
</div>
</form>
</div>
</div>
</div>
the plugins i used
The following article is an answer to a similiar question, you might wanna take a look: https://stackoverflow.com/a/16095583/12739653
If it didn't help you. Please provide some general information; Did you import all required files, what's your Bootstrap version?
If you're using Bootstrap 5, you might need to use data-bs-target and data-bs-toggle instead. Learn more here: https://getbootstrap.com/docs/5.0/components/modal/#live-demo
Just make sure that your <div class="modal fade" ...> is inside the <body>.

Show modal if not logged in

I'm trying to make a modal popup display allowing you to log in but only if you are not logged in.
I have tried many solutions but so far can only get the login to display in a new page.
Please see my code below
index.php
<?php
require 'database_connection.php';
if (!isset($_SESSION["type"])) {
echo "<script>$('#loginModal').modal('show');</script>";
}
require 'includes/header.php';
?>
***
***
if session type is
set code goes here
***
***
<div id="loginModal" class="modal fade">
<div class="modal-dialog">
<form method="post" id="product_form">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><i class="fa fa-plus"></i> Add Product</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Stock Code</label>
<input type="text" name="product_name" id="product_name" class="form-control" required disabled />
</div>
<div class="form-group">
<label name="category_label" id="category_label">Category</label>
<select name="category_id" id="category_id" class="form-control" required>
<option value="">Select Category</option>
<?php echo fill_category_list($connect);?>
</select>
</div>
<div class="form-group">
<label>Enter Product Quantity</label>
<div class="input-group">
<input type="text" name="product_quantity" id="product_quantity" class="form-control" required pattern="[+-]?([0-9]*[.])?[0-9]+" placeholder="Enter Qty" />
<span class="input-group-addon">
<select class="form-control" name="product_unit" id="product_unit" required disabled>
<option value="Box">Boxes</option>
</select>
</span>
</div>
</div>
<div class="form-group">
<label>Location</label>
<input type="text" name="product_location" id="product_location" class="form-control" required disabled />
</div>
</div>
<div class="modal-footer">
<input type="hidden" name="product_id" id="product_id" />
<input type="hidden" name="btn_action" id="btn_action" />
<input type="submit" name="action" id="action" class="btn btn-success" value="Add" />
</div>
</div>
</form>
</div>
</div>
database_connection.php
<?php
$connect = new PDO('mysql:host=localhost;dbname=continental3', 'root', 'password');
session_start();
?>
What am I missing?
On a side note if there is an easier or better way of doing this I'm happy to change my approach
Any help would be greatly appreciated
** UPDATE**
<?php
require 'database_connection.php'; //checks session type is set or not
require 'includes/header.php'; // Loads css and js files
if (!isset($_SESSION["type"])) { //session check
echo '<script>$(document).ready(function(){$("#loginModal").modal("show");});</script>';
} //open modal
require 'function.php';
require 'includes/navbar.php';
?>
The above code shows the modal as expected but only after the page has loaded. removing the document ready function the modal does not load but the rest of the page loads and displays (presumably because I do not use the else condition. When using the else condition as seen below nothing loads.
<?php
require 'database_connection.php';
require 'includes/header.php';
if (!isset($_SESSION["type"])) { ?>
echo '<script>$(document).ready(function(){$("#loginModal").modal("show");});</script>';
<?php } else {
require 'function.php';
require 'includes/navbar.php';
?>
***
***
if session type is
set code goes here
***
***
<div id="loginModal" class="modal fade">
<div class="modal-dialog">
<form method="post" id="product_form">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><i class="fa fa-plus"></i> Add Product</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Stock Code</label>
<input type="text" name="product_name" id="product_name" class="form-control" required disabled />
</div>
<div class="form-group">
<label name="category_label" id="category_label">Category</label>
<select name="category_id" id="category_id" class="form-control" required>
<option value="">Select Category</option>
<?php echo fill_category_list($connect);?>
</select>
</div>
<div class="form-group">
<label>Enter Product Quantity</label>
<div class="input-group">
<input type="text" name="product_quantity" id="product_quantity" class="form-control" required pattern="[+-]?([0-9]*[.])?[0-9]+" placeholder="Enter Qty" />
<span class="input-group-addon">
<select class="form-control" name="product_unit" id="product_unit" required disabled>
<option value="Box">Boxes</option>
</select>
</span>
</div>
</div>
<div class="form-group">
<label>Location</label>
<input type="text" name="product_location" id="product_location" class="form-control" required disabled />
</div>
</div>
<div class="modal-footer">
<input type="hidden" name="product_id" id="product_id" />
<input type="hidden" name="btn_action" id="btn_action" />
<input type="submit" name="action" id="action" class="btn btn-success" value="Add" />
</div>
</div>
</form>
</div>
</div>
<?php } #close else ?>
Where did you set $_SESSION['type'] ???
Please try this
index.php
<?php
require 'database_connection.php';
if (!isset($_SESSION["type"])) { ?>
<script> $('#loginModal').modal('show'); </script>";
<?php } else {
require 'includes/header.php';
?>
***
***
if session type is
set code goes here
***
***
<div id="loginModal" class="modal fade">
<div class="modal-dialog">
<form method="post" id="product_form">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><i class="fa fa-plus"></i> Add Product</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Stock Code</label>
<input type="text" name="product_name" id="product_name" class="form-control" required disabled />
</div>
<div class="form-group">
<label name="category_label" id="category_label">Category</label>
<select name="category_id" id="category_id" class="form-control" required>
<option value="">Select Category</option>
<?php echo fill_category_list($connect);?>
</select>
</div>
<div class="form-group">
<label>Enter Product Quantity</label>
<div class="input-group">
<input type="text" name="product_quantity" id="product_quantity" class="form-control" required pattern="[+-]?([0-9]*[.])?[0-9]+" placeholder="Enter Qty" />
<span class="input-group-addon">
<select class="form-control" name="product_unit" id="product_unit" required disabled>
<option value="Box">Boxes</option>
</select>
</span>
</div>
</div>
<div class="form-group">
<label>Location</label>
<input type="text" name="product_location" id="product_location" class="form-control" required disabled />
</div>
</div>
<div class="modal-footer">
<input type="hidden" name="product_id" id="product_id" />
<input type="hidden" name="btn_action" id="btn_action" />
<input type="submit" name="action" id="action" class="btn btn-success" value="Add" />
</div>
</div>
</form>
</div>
</div>
<?php } #close else ?>
database_connection.php
<?php
$connect = new PDO('mysql:host=localhost;dbname=continental3', 'root', 'password');
session_start();
?>

$_POST method turns empty

Firstable, hello everyone. I have issue about the $_POST method, when I write this code block;
if (isset($_POST['menuduzenle'])) {
$menu_id=$_POST['menu_id']; //It didn't turn with value in mysql
$ayarguncelle=mysql_query("update menuler set menu_ad='".$_POST['menu_ad']."',menu_link='".$_POST['menu_link']."'where menu_id='$menu_id'");
if(mysql_affected_rows())
{
header("Location:../menuleriduzenle.php?guncelleme=basarili&menu_id=$menu_id");
}else{
header("Location:../menuleriduzenle.php?guncelleme=basarisiz&menu_id=$menu_id");}
}
menu_id turns emty, what I need to do for solve this?
and here it's html code
form
<form action="network/islem.php" method="POST">
<div class="col-md-12">
<div class="form-group col-md-9">
<label>Menu Adı: </label>
<input class="form-control" name="menu_ad" value="<?php echo $menucek['menu_ad']; ?>" />
</div>
</div>
<div class="col-md-12">
<div class="form-group col-md-9">
<label>Menu Link: </label>
<input class="form-control" name="menu_link" value="<?php echo $menucek['menu_link']; ?>" />
</div>
</div>
<div class="col-md-12">
<div class="form-group col-md-6">
<input class="btn btn-primary col-md-3" type="submit" name="menuduzenle" value="Edit Menu">
</div>
</form>
and
<td><button class="btn btn-primary col-md-12">Edit</button></td>
You not send any one input with name 'menu_id' on your from.
<form action="network/islem.php" method="POST">
<div class="col-md-12">
<div class="form-group col-md-9">
<label>Menu Adı: </label>
<input class="form-control" name="menu_ad" value="<?php echo $menucek['menu_ad']; ?>" />
</div>
</div>
<div class="col-md-12">
<div class="form-group col-md-9">
<label>Menu Link: </label>
<input class="form-control" name="menu_link" value="<?php echo $menucek['menu_link']; ?>" />
</div>
</div>
<div class="col-md-12">
<div class="form-group col-md-6">
<input class="btn btn-primary col-md-3" type="submit" name="menuduzenle" value="Edit Menu">
</div>
<input type="hidden" name="menu_id" value="<?php echo $_GET['menu_id'] ?>" />
</form>
You input name "menu_ad" would be "menu_id" or fault other input with name "menu_id" on you sample.

What's wrong with my button?

`<div class="tab-content">
<div class="row">
<div class="col-lg-6">
<form method="post" data-toggle="modal" enctype="multipart/form-data" action="data/pegawai/proses.php">
<div class="form-group">
<label>NIP</label>
<input class="form-control" name="nip" type="text" value="<?php echo $r['nip'];?>" readonly="">
</div>
<div class="form-group">
<label>Nama Lengkap</label>
<input class="form-control" type="text" value="<?php echo $r['nm_pegawai'];?>" name="nama" placeholder="Nama Lengkap" autofocus="" required="">
</div>
<div class="form-group">
<label>Jenis Kelamin</label>
<div class="radio">
<label class="radio-inline">
<input type="radio" name="jk" id="optionsRadiosInline1" value="Laki-laki" <?php $ob->cek("Laki-laki",$r['jenis_kelamin'],"radio") ?>>Laki-laki
</label>
<label class="radio-inline">
<input type="radio" name="jk" id="optionsRadiosInline2" value="perempuan" <?php $ob->cek("Perempuan",$r['jenis_kelamin'],"radio") ?>>perempuan
</label>
</div>
</div>
<div class="form-group">
<label>Tempat Lahir</label>
<input class="form-control" type="text" value="<?php echo $r['tempat_lahir'];?>" name="tmp_lahir" placeholder="Tempat Lahir" required="">
</div>
<div class="form-group">
<label>Tanggal Lahir</label>
<input type="date" name="tgl_lahir" value="<?php echo $r['tanggal_lahir'];?>" class="form-control" placeholder="Tanggal Lahir" required="">
</div>
<div class="form-group">
<label>Agama</label>
<select class="form-control" name="agama" required="">
<option <?php $ob->cek("Islam",$r['agama'],"select") ?> value="Islam">Islam</option>
<option <?php $ob->cek("Kristen",$r['agama'],"select") ?> value="Kristen">Kristen</option>
<option <?php $ob->cek("Katholik",$r['agama'],"select") ?> value="Katholik">Katholik</option>
<option <?php $ob->cek("Protestan",$r['agama'],"select") ?> value="Protestan">Protestan</option>
<option <?php $ob->cek("Hindu",$r['agama'],"select") ?> value="Hindu">Hindu</option>
<option <?php $ob->cek("Budha",$r['agama'],"select") ?> value="Budha">Budha</option>
</select>
</div>
<div class="form-group">
<label>Alamat</label>
<textarea class="form-control" name="alamat" rows="3" placeholder="Alamat Lengkap" required=""><?php echo $r['alamat'];?></textarea>
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label>Nomor Telepon</label>
<input class="form-control" type="text" value="<?php echo $r['no_telp'];?>" name="telp" onkeypress="return isNumberKey(event)" maxlength="15" placeholder="Nomor telepon" required="">
</div>
<div class="form-group">
<label>Tahun Masuk</label>
<input class="form-control" type="text" value="<?php echo $r['tahun_masuk'];?>" name="thn_masuk" placeholder="Tahun Masuk" onkeypress="return isNumberKey(event)" maxlength="4" required="">
</div>
<div class="form-group">
<label>Bagian</label>
<select class="form-control" name="bagian" required="">
<option <?php $ob->cek("Teller",$r['bagian'],"select") ?> value="Teller">Teller</option>
<option <?php $ob->cek("CSO",$r['bagian'],"select") ?> value="CSO">CSO</option>
<option <?php $ob->cek("BO",$r['bagian'],"select") ?> value="BO">BO</option>
</select>
</div>
<div class="form-group">
<label>Cabang</label>
<?php
echo '<select class="form-control" name="cabang" required="">';
$query=mysql_query("
SELECT *
FROM bank");
while($entry1=mysql_fetch_array($query))
{
echo "<option";
if($entry1['kd_bank']==$r['kd_bank']){echo " selected=selected";}
echo " value='".$entry1['kd_bank']."'>" . $entry1['nm_bank'] . "</option>";
}
echo "</select>";
?>
</div>
<div class="form-group">
<label>Kata Sandi</label>
<input class="form-control" type="password" value="<?php echo $r['password']?>" name="password" placeholder="Kata Sandi">
</div>
</div>
<!-- /.col-lg-6 (nested) -->
</div>
<!-- /.row (nested) -->
<div class="modal-footer">
<button type="button" name="ubah" class="btn btn-primary">Ubah</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</form>
</div> `
my source code, my button cannot active, how to solving it?
Thank you
Pandhu
Make your button type as "submit" like below.
<button type="submit" name="ubah" class="btn btn-primary">Ubah</button>
Else you can also keep it as button, but in that case u need to use ajax(javascript) and onclick event on button , for example :
<button type="button" name="ubah" class="btn btn-primary" onclick="save()">Ubah</button>
where save() is some function in javascript that you will create to save the form data.

Two Forms In a HTML Document

I am having a form as below.
<div class="container">
<form method="post" action="index.php">
<div id="rule">
<div class="row">
<div class="span5">
<input type="text" class="input-xlarge" value="Rule Name"/>
</div>
<div class="span6">
<input type="text" class="input-xxlarge" value="Description"/>
</div>
<div class="clearfix"> </div>
</div>
</div>
<br />
<div id="sel" class="select">
<div class="row">
<div class="span1 offset2">
<p class="btn btn-danger">If</p>
</div>
<div class="span2">
<select class="span2" name="metrics">
<option value="bounce_rate">Bounce Rate</option>
<option value="location">Locations</option>
<option value="social_media">Social Media</option>
<option value="search">Search</option>
<option value="visits">Visitors</option>
</select>
</div>
<div class="span1">
<select name="conditions" class="span2">
<option value=">">></option>
<option value="<"><</option>
<option value=">=">>=</option>
<option value="<="><=</option>
<option value="=">=</option>
</select>
</div>
<div class="span1 offset1">
<input type="text" name="percentage" class="input-small"/>
</div>
<div class="clearfix"> </div>
</div>
<br />
<div class="row">
<div class="span1 offset2">
<p class="btn btn-danger">Period</p>
</div>
<div class="span3">
<div class="input-append date datepicker" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
<input class="span2" size="16" type="text" value="12-02-2012" />
<span class="add-on"><i class="icon-th"></i></span>
</div>
</div>
<div class="span3">
<div class="input-append date datepicker" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
<input class="span2" size="16" type="text" value="12-02-2012" />
<span class="add-on"><i class="icon-th"></i></span>
</div>
</div>
<div class="clearfix"> </div>
</div>
</div>
<div id="dyna"></div>
<div id="end">
<div class="row">
<div class="span1">
<p class="btn btn-danger">THEN</p>
</div>
<div class="span3">
<input type="text" class="input-xlarge" value="Statement" />
</div>
<div class="clearfix"> </div>
</div>
<div class="row">
<div class="span1">
<p class="btn btn-danger">ELSE</p>
</div>
<div class="span3">
<input type="text" class="input-xlarge" value="Statement" />
</div>
<div class="clearfix"> </div>
</div>
<div class="row">
<button class="span1 btn btn-success" type="submit" value="submit">Submit</button>
<div class="span2 offset9">
<p class="btn btn-success input-small" id="addRule">Add Rule </p>
</div>
<div class="clearfix"> </div>
</div>
</div>
</form>
</div>
I have included a button 'Add Rule' to create a dynamic elements within the above . So I used a javascript for creating dynamic elements as same of above.
The javascript as below.
<script type="text/javascript">
$('.datepicker').datepicker();
(function(){
var i = 0;
$("#addRule").live('click',function(){
++i;
var $ctrl = $('<div id="'+ i +'" class="select"><div class="row"><div class="span1 offset2"><button class="btn btn-danger">If</button></div><div class="span2"><select class="span2" name="metrics"><option value="bounce_rate">Bounce Rate</option><option value="location">Locations</option><option value="social_media">Social Media</option><option value="search">Search</option><option value="visits">Visitors</option></select></div><div class="span1"><select name="conditions" class="span2"><option value=">">></option><option value="<"><</option><option value=">=">>=</option><option value="<="><=</option><option value="=">=</option></select></div><div class="span1 offset1"><input type="text" name="percentage" class="input-small"/></div><div class="span2 offset1"><button class="btn btn-danger remove" id="'+ i +'">Remove</button></div><div class="clearfix"> </div></div><br /><div class="row"><div class="span1 offset2"><p class="btn btn-danger">Period</p></div><div class="span3"><div class="input-append date datepicker" data-date="12-02-2012" data-date-format="dd-mm-yyyy"><input class="span2" size="16" type="text" value="12-02-2012" /><span class="add-on"><i class="icon-th"></i></span></div></div><div class="span3"><div class="input-append date datepicker" data-date="12-02-2012" data-date-format="dd-mm-yyyy"><input class="span2" size="16" type="text" value="12-02-2012" /><span class="add-on"><i class="icon-th"></i></span></div></div><div class="clearfix"> </div></div></div>');
$("#dyna").append($ctrl);
$('.datepicker').datepicker();
});
}) ();
(function(){
$(".remove").live('click',function(){
var remDiv = $(this).attr('id');
//var questionList = "questionList"+remQ;
$("#" + remDiv).remove();
});
}) ();
So I wanna get the values once i click the submit button. Is it correct way what i am using only a form for fetching the data or am i create two forms separately? So how to do that?
You do not need to create a second form if you are inserting the new elements into the existing form and as long as they have different names from any existing inputs you want to receive.
You can create a second form if you want different submit buttons for the two different collections of input data.

Categories