bootstrap modal form-inline won't "inline" buttons - bootstrap-modal

i'm really stuck with this problem. Created the next modal .form-inline but the cancel button stays out of the inline, this is the code:
<div id="loginModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Login </h4>
</div>
<div class="modal-body">
<div class="form-inline">
<div class="form-group">
<label class="sr-only" for="email">Email Address</label>
<input type="email" class="form-control-input-sm text-center" placeholder="Email">
</div>
<div class="form-group">
<label class="sr-only" for="password">Password</label>
<input type="password" class="form-control-input-sm text-center" placeholder="Password">
</div>
<input type="checkbox"><span style="color:#9d9797">Remember me</span>
<button type="submit" class="btn btn-info">Sign In</button>
<button type="button" class="btn btn-default btn-sm"
data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
</div>
The picture of it:

The default input max-width is 280px, you can define a class to decrease it, such as
<style>
.input-short {
max-width: 130px !important;
}
</style>
then apply it to the input textboxes
<input type="email" class="form-control input-short" id="email" placeholder="Email">
This should give you what you want (adjust the max-width accordingly).

Related

One Bootstrap Modal affects the other

I have two bootstrap modals on a page. The first one (Modal_Add) will not work except if the second one (Modal_Edit) is first opened. The text boxes will not be clickable and nothing can be typed. But when I open the second one - without doing anything on it - and close, then open the first that was not working, it works. below are the codes
<!-- MODAL ADD -->
<form id="add_form" enctype="multipart/form-data">
<div class="modal fade" id="myModal" role="dialog" tabindex="-1" aria-labelledby="exampleModalLabelA" aria-hidden="true">
<div class="modal-dialog" >
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h5 class="modal-title" id="exampleModalLabelB">Add New Member</h5>
</div>
<div class="modal-body">
<div class="container-fluid">
<input type="hidden" name="member_units" id="member_units" value="<?php if (isset($units_code)){echo $units_code;}?>" class="form-control">
<div class="row-fluid">
<div class="span6">
<div class="col-md-8">
<label class="col-form-label">Entrance Fee</label>
</div>
</div>
<div class="span6">
<div class="col-md-8">
<input type="text" name="entrance_amount" id="entrance_amount" class="form-control" placeholder="Entrance Fee">
<span id="entrance_amount_error" class="label label-important"></span>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span6">
<label class="col-md-4 col-form-label">Member Name</label>
<div class="col-md-8">
<input type="text" name="member_name" id="member_name" class="form-control" placeholder="Name"> <span id="member_name_error" class="label label-important"></span>
</div>
</div>
<div class="span6">
<label class="col-md-4 col-form-label">Address</label>
<div class="col-md-8">
<input type="text" name="member_address" id="member_address" class="form-control" placeholder="Address">
</div>
</div>
</div>
<div class="row-fluid">
<div class="span6">
<label class="col-md-4 col-form-label">Member Phone</label>
<div class="col-md-8">
<input type="text" maxlength="11" name="member_phone" id="member_phone" class="form-control" placeholder="Phone">
<span id="member_phone_error" class="label label-important"></span>
</div>
</div>
<div class="span6">
<label class="col-md-4 col-form-label">Gender Status</label>
<div class="col-md-8">
<select name="gender_status" id="gender_status" class="form-control tooltips" data-trigger="hover" data-original-title="choose a Gender Status" >
<option value="0">--select--</option>
<option value="male">Male</option>
<option value="female">Female</option>
<option value="company">Company</option>
<option value="society">Society</option>
</select>
<span id="gender_status_error" class="label label-important"></span>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span6">
<label class="col-md-4 col-form-label">Banker</label>
<div class="col-md-8">
<input type="text" name="banker" id="banker" class="form-control" placeholder="Banker">
<span id="banker_error" class="label label-important"></span>
</div>
</div>
<div class="span6">
<label class="col-md-4 col-form-label">Account Number</label>
<div class="col-md-8">
<input type="text" name="accountno" id="accountno" class="form-control" placeholder="Account Number" maxlength="10">
<span id="accountno_error" class="label label-important"></span>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span6">
<label class="col-md-4 col-form-label" id="g-label">Guarantors</label>
<div class="col-md-8">
<select data-placeholder="Type Guarantors" name="guarantors[]" id="guarantors" class="chosen" multiple="multiple">
<!-- <option value="0">A</option> -->
</select>
</div>
</div>
<div class="span6">
<label class="col-md-4 col-form-label">Means of ID</label>
<div class="col-md-8">
<input type="text" maxlength="11" name="id_means" id="id_means" class="form-control" placeholder="Type your NIN">
<span id="id_means_error" class="label label-important"></span>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span6">
<label class="col-md-4 col-form-label">Date Joined</label>
<div class="col-md-8">
<input type="date" name="date_joined" id="date_joined" class="form-control datepicker" value="<?php echo date('Y-m-d'); ?>">
</div>
</div>
<div class="span6">
<label class="col-md-4 col-form-label">Upload Passport</label>
<div class="col-md-8">
<input type='file' name='userfile' size='20' />
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" id="btn_save" class="btn btn-primary">Save</button>
</div>
</div>
</div>
</div>
</form>
<!--END MODAL ADD-->
<!-- MODAL EDIT -->
<form id="edit_form" enctype="multipart/form-data">
<div class="modal fade" id="Modal_Edit" role="dialog" tabindex="-1" aria-labelledby="exampleModalLabelE" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h5 class="modal-title" id="exampleModalLabelF">Edit Member</h5>
</div>
<div class="modal-body">
<div class="container-fluid">
<input type="hidden" name="member_units" id="member_units" value="<?php if (isset($units_code)){echo $units_code;}?>" class="form-control">
<div class="row-fluid">
<label class="col-md-4 col-form-label">Union Code</label>
<div class="col-md-8">
<input type="hidden" name="member_code_edit" id="member_code_edit" class="form-control" placeholder="Member Code" readonly>
<input type="text" name="union_code_edit" id="union_code_edit" class="form-control" placeholder="Union Code" readonly>
</div>
</div>
<div class="row-fluid">
<div class="span6">
<label class="col-md-4 col-form-label">Member Name</label>
<div class="col-md-8">
<input type="text" name="member_name_edit" id="member_name_edit" class="form-control" placeholder="Name">
<span id="member_name_edit_error" class="label label-important"></span>
</div>
</div>
<div class="span6">
<label class="col-md-4 col-form-label">Address</label>
<div class="col-md-8">
<input type="text" name="member_address_edit" id="member_address_edit" class="form-control" placeholder="Address">
</div>
</div>
</div>
<div class="row-fluid">
<div class="span6">
<label class="col-md-4 col-form-label">Member Phone</label>
<div class="col-md-8">
<input type="text" maxlength="11" name="member_phone_edit" id="member_phone_edit" class="form-control" placeholder="Phone">
<span id="member_phone_edit_error" class="label label-important"></span>
</div>
</div>
<div class="span6">
<label class="col-md-4 col-form-label">Means of ID</label>
<div class="col-md-8">
<input type="text" maxlength="11" name="id_means_edit" id="id_means_edit" class="form-control" placeholder="Type your NIN">
<span id="id_means_edit_error" class="label label-important"></span>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span6">
<label class="col-md-4 col-form-label">Banker</label>
<div class="col-md-8">
<input type="text" name="banker_edit" id="banker_edit" class="form-control" placeholder="Banker">
<span id="banker_edit_error" class="label label-important"></span>
</div>
</div>
<div class="span6">
<label class="col-md-4 col-form-label">Account Number</label>
<div class="col-md-8">
<input type="text" name="accountno_edit" id="accountno_edit" class="form-control" placeholder="Account Number" maxlength="10">
<span id="accountno_edit_error" class="label label-important"></span>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span6">
<label class="col-md-4 col-form-label">Date Joined</label>
<div class="col-md-8">
<input type="date" name="date_joined_edit" id="date_joined_edit" class="form-control datepicker" value="" readonly="">
</div>
</div>
<div class="span6">
<label class="col-md-4 col-form-label">Upload Passport</label>
<div class="col-md-8">
<input type='file' name='userfile_edit' size='20'/>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span6">
<label class="col-md-4 col-form-label" id="g-label">Current Guarantors</label>
<div class="col-md-8">
<div id="current_gurantors"></div>
<!-- <option value="0">A</option> -->
</div>
</div>
<div class="span6">
<label class="col-md-4 col-form-label" id="g-label">Guarantors</label>
<div class="col-md-8">
<select data-placeholder="Type Guarantors" name="guarantors_edit[]" id="guarantors_edit" class="chosen" multiple="multiple">
<!-- <option value="0">A</option> -->
</select>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" id="btn_update" class="btn btn-primary">Update</button>
</div>
</div>
</div>
</div>
</form>
<!--END MODAL EDIT-->
However, when i put the code for Modal_Edit on top of the code for Modal_Add, the problem affects Modal_Edit and vice versa
Edited
when I copied the code to https://www.codeply.com/p?starter=Bootstrap it works fine. What could be the problem?

How to open a Bootstrap modal using jQuery?

I'm using Twitter Bootstrap modal window functionality. When someone clicks submit on my form, I want to show the modal window upon clicking the "submit button" in the form.
<form id="myform" class="form-wizard">
<h2 class="form-wizard-heading">BootStap Wizard Form</h2>
<input type="text" value=""/>
<input type="submit"/>
</form>
<!-- Modal -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary">Save changes</button>
</div>
</div>
$('#myform').on('submit', function(ev) {
$('#my-modal').modal({
show: 'false'
});
var data = $(this).serializeObject();
json_data = JSON.stringify(data);
$("#results").text(json_data);
$(".modal-body").text(json_data);
// $("#results").text(data);
ev.preventDefault();
});
I have check demo from this website
https://bootstrapmodal.com
There was some missing divs in your modal that I have included below (modal-dialog and modal-content classes)
Also added a name attribute to your input so you can serialize it with serialize() according to https://api.jquery.com/serialize/
$('#myform').on('submit', function(ev) {
$('#myModal').modal('show');
var data = $(this).serialize();
json_data = JSON.stringify(data);
$("#results").text(json_data);
$(".modal-body").text(json_data);
// $("#results").text(data);
ev.preventDefault();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.0/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-SI27wrMjH3ZZ89r4o+fGIJtnzkAnFs3E4qz9DIYioCQ5l9Rd/7UAa8DHcaL8jkWt" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.0/js/bootstrap.min.js" integrity="sha384-3qaqj0lc6sV/qpzrc1N5DC6i1VRn/HyX4qdPaiEFbn54VjQBEU341pvjz7Dv3n6P" crossorigin="anonymous"></script>
<form id="myform" class="form-wizard">
<h2 class="form-wizard-heading">BootStap Wizard Form</h2>
<input type="text" name="text" value=""/>
<input type="submit"/>
</form>
<!-- Modal -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h3 id="myModalLabel">Modal header</h3>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>

Angular 7 Hide bootstrap modal in typscript

I want to call (click)="basicModal.hide()" methode of MDBootstrap Modal inside one of my fuctions in my typescript component. I don't know how to access this method from component.
<button type="button" mdbBtn color="primary" class="relative waves-light" (click)="basicModal.show()" mdbWavesEffect>Launch demo modal</button>
<div mdbModal #basicModal="mdbModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myBasicModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close pull-right" aria-label="Close" (click)="basicModal.hide()">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title w-100" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" mdbBtn color="secondary" class="waves-light" aria-label="Close" (click)="basicModal.hide()" mdbWavesEffect>Close</button>
<button type="button" mdbBtn color="primary" class="relative waves-light" mdbWavesEffect>Save changes</button>
</div>
</div>
</div>
</div>
You have to use the Angular's #ViewChild decorator to target the mdbModal directrive, and then use the hide() method from ModalDirective class.
Please take a look at the below code, there's explained everything:
.html:
<button type="button" mdbBtn color="primary" class="relative waves-light" (click)="basicModal.show()" mdbWavesEffect>Launch demo modal</button>
<div #modal mdbModal #basicModal="mdbModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myBasicModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close pull-right" aria-label="Close" (click)="basicModal.hide()">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title w-100" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
<div class="md-form">
<input type="text" class="form-control" id="input1" mdbInput>
<label for="input1">Modal input</label>
</div>
</div>
<div class="modal-footer">
<button mdbBtn color="primary" mdbWavesEffect (click)="hideModal()">Hide modal</button>
</div>
</div>
</div>
</div>
.ts:
#ViewChild(ModalDirective) modal: ModalDirective;
hideModal() {
this.modal.hide();
}
If there will be something unclear, feel free to ask again!

Bootstrap modal as dropdown

<div id="lastcolumn" class="col-md-3">
<ul class="nav navbar-nav pull-right">
<li class="llogin"><a class="mlogin" data-target="#loginmodal" data-toggle="modal"><span class="glyphicon glyphicon-chevron-down pull-right"></span>Login</a></li>
<div class="modal" id="loginmodal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="Username">Username</label>
<input type="text" name="text" class="form-control">
</div>
<div class="form-group">
<label for="Password">Password</label>
<input type="Password" name="text" class="form-control">
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<li class="lsignup"><a class="msignup"><span class="glyphicon glyphicon-chevron-down pull-right"></span>Signup</a></li>
<li class="lcart"><a class="mcart"><span class="glyphicon glyphicon-shopping-cart pull-right"></span>Item</a></li>
</ul>
</div>
</div>
</div>
I want to show bootstrap modal as dropdown under login currently my modal is showing in middle of the screen what i have to do to achieve the desired behaviour, kindly help.enter image description here
Move the .modal div in the li that you want to attach the modal with. Then define position:relative; for that li and position:absolute; for that .modal.
Here's a working snippet. I removed the .modal-backdrop and edited padding and margin for modal. You can ignore them since they are not relevant to the basic problem.
.nav.navbar-nav li{
float:left;
}
.nav.navbar-nav li a.mlogin{
position:relative;
}
div.modal#loginmodal{
position:absolute;
width:200px;
height:300px;
top:30px;
left:0;
padding:0;
margin:0;
}
div.modal#loginmodal .modal-footer{
padding:5px;
margin:0;
}
div.modal#loginmodal .modal-body{
padding:10px 20px;
margin:0;
}
div.modal#loginmodal .modal-header{
padding:5px 20px;
margin:0;
}
.modal-backdrop{
display:none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div id="lastcolumn" class="col-md-3">
<ul class="nav navbar-nav pull-right">
<li class="llogin"><a class="mlogin" data-target="#loginmodal" data-toggle="modal"><span class="glyphicon glyphicon-chevron-down pull-right"></span>Login</a>
<div class="modal" id="loginmodal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="Username">Username</label>
<input type="text" name="text" class="form-control">
</div>
<div class="form-group">
<label for="Password">Password</label>
<input type="Password" name="text" class="form-control">
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</li>
<li class="lsignup"><a class="msignup"><span class="glyphicon glyphicon-chevron-down pull-right"></span>Signup</a></li>
<li class="lcart"><a class="mcart"><span class="glyphicon glyphicon-shopping-cart pull-right"></span>Item</a></li>
</ul>
</div>

In line view of forms in modal

I am using Bootstrap modal.
The following is my code.
<!-- Modal -->
<div class="modal fade" id="editModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4>Edit Equifax Credit Score Data</h4>
</div>
<div class="modal-body form-horizontal">
<div class="form-group row">
<label for="name" class="col-sm-2 col-form-label">Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="equiFaxName"
placeholder="Name" readonly="readonly" />
</div>
</div>
<div class="form-group row">
<label for="startRangeModal" class="col-sm-2 col-form-label">Start
Range</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="startRangeModal"
placeholder="Start Range" />
</div>
</div>
<div class="form-group row">
<label for="endRangeModal" class="col-sm-2 col-form-label">End
Range</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="endRangeModal"
placeholder="End Range" />
</div>
</div>
<div class="form-group row required">
<label for="riskGradeModal" class="col-sm-2 col-form-label">Risk
Grade </label>
<div class="col-sm-10">
<input type="text" class="form-control" id="riskGradeModal"
placeholder="Risk Range" />
</div>
</div>
<div class="form-group row required">
<label for="agentRiskGradeModal" class="col-sm-2 col-form-label">Agent
Display Grade</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="agentRiskGradeModal"
placeholder="Agent Display Grade" />
</div>
</div>
<div class="form-group row required">
<label for="hitCode" class="col-sm-2 col-form-label"> Hit
Code</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="hitCodeModal"
placeholder="Hit Code" />
</div>
</div>
<div class="form-group row required">
<label for="hitCodeResponse" class="col-sm-2 col-form-label">
Hit Code</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="hitCodeResponseModal"
placeholder="Hit Code Response" />
</div>
</div>
<div class="form-group row required">
<label for="approvalTypeListModal" class="col-sm-2 col-form-label">Approval
Type</label> <select id="approvalTypeListModal" class="form-control">
</select>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-primary"
data-dismiss="modal">Cancel</button>
<button class="btn btn-success"
id="submitEditModalData">Save</button>
</div>
</div>
</div>
</div>
In the modal all the form inputs are inline horizontal but the select tag shows below the label and is not inline with the label.
Can someone help me in putting the select box in line and not below the label.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="form-group row required">
<label for="approvalTypeListModal" class="col-md-2 col-sm-2 col-xs-2 col-form-label">Approval
Type
</label>
<div class="col-md-10 col-sm-10 col-xs-10">
<select id="approvalTypeListModal" class="form-control">
<option value="option1">Option1</option>
</select>
</div>
</div>
You forgot to put class col-md-* .
You can put it in select tag or can make a new div and give it to that class.
Hope this helps.