how to make a transparent modal in bootstrap? - html

I am using Bootstrap to create a modal. It is in a Navbar and if we click on the Login or Signup button, the modal appears. The Navbar is transparent in color unless you hover on it so that it turns white. I want the Modal to be transparent as well but it is transparent relative to the color of the Navbar which is white. Say my background is red in color, the modal will appear white instead of red and I want it to look red.
Here's my modal
<!--Login-->
<li class="nav-item">
<div class="col-md-auto col-sm-auto col-auto" style="margin: 1vw;">
<!-- Button trigger modal -->
<button type="button" class="btn btn1" data-bs-toggle="modal" data-bs-target="#LoginModal">
Login
</button>
<!-- Modal -->
<div class="modal fade" id="LoginModal" tabindex="-1" aria-labelledby="LoginModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header text-dark bg1">
<h5 class="modal-title" id="LoginModalLabel">Login</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body text-dark bg1">
<!--Form-->
<form>
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">Email
address</label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
<div id="emailHelp" class="form-text">We'll never share your email
with anyone else.</div>
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1">
</div>
<div class="mb-3 form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1">
<label class="form-check-label" for="exampleCheck1">Check me
out</label>
</div>
<button type="submit" class="btn btn-primary" data-bs-dismiss="modal">Submit</button>
</form>
</div>
<div class="modal-footer text-dark bg1">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</li>
Here's my CSS:
.navbar{
background-color: transparent;
}
.navbar:hover{
background-color: white;
}
.btn1:hover{
color: blueviolet;
}
.bg1{
background-color: transparent;
}
body{
background-color: tomato;
}

I don’t know if the background-color for your modal is getting set because you have it as a child of the navbar (you didn’t include a working snippet, so it’s not possible to see your code in action), but I tried your setup with the modal separate from the navbar and it seems to work (i.e. the modal is transparent).
I added transitions and hover effects for the background colors for the navbar and the modal so you can see it in operation.
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.1/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/#popperjs/core#2.9.2/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.1/dist/js/bootstrap.min.js"></script>
<style>
body {
background-color: tomato;
}
.navbar {
background-color: transparent;
transition: background-color 0.3s ease-in-out;
}
.navbar:hover {
background-color: white;
}
.btn1:hover {
color: blueviolet;
}
.bg1 {
background-color: transparent;
}
#LoginModal .modal-content {
background-color: transparent;
transition: background-color 0.3s ease-in-out;
}
#LoginModal .modal-content:hover {
background-color: white;
}
</style>
<nav class="navbar navbar-expand-lg navbar-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<button type="button" class="btn btn1" data-bs-toggle="modal" data-bs-target="#LoginModal">
Login
</button>
</li>
</ul>
</div>
</div>
</nav>
<!-- Modal -->
<div class="modal fade" id="LoginModal" tabindex="-1" aria-labelledby="LoginModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header text-dark bg1">
<h5 class="modal-title" id="LoginModalLabel">Login</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body text-dark bg1">
<!--Form-->
<form>
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">Email
address</label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
<div id="emailHelp" class="form-text">We'll never share your email
with anyone else.</div>
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1">
</div>
<div class="mb-3 form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1">
<label class="form-check-label" for="exampleCheck1">Check me
out</label>
</div>
<button type="submit" class="btn btn-primary" data-bs-dismiss="modal">Submit</button>
</form>
</div>
<div class="modal-footer text-dark bg1">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>

Related

the webpage contains three bootstrap modals, the first two modals are loaded with ajax contents, while the third is an html form

my problem is all the modals especially the third modal with html form works perfectly when the webpage is refreshed and the third modal is fired first. but if any of the other two modal is launched beforehand, then the third modal load the contents of the last launched modal only instead of its own html contents. the code is here below:
' class='btn btn-info btn-sm btn-popup'>VIEW NOTESHEET
' class='btn btn-info btn-sm btn-remark'>VIEW REMARKS
ADD DOCUMENT
<div class="modal fade bd-example-modal-xl" id="notesheetModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalScrollableTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-scrollable modal-xl" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalScrollableTitle">Notesheet for File no: <?php echo $fileNo;?></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- tinymce Editor modal-->
<!-- Modal -->
<!-- end tinyMCE -->
<div class="modal fade bd-example-modal-xl" id="myModal3" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog modal-xl" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Add New Document</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<!------------------------------------------------add document------------------------------------------------------------------------------------------------------------------------------------------------------->
<div class="p-5 bg-white rounded shadow mb-5">
<!-- Rounded tabs -->
<ul id="myTab" role="tablist" class="nav nav-tabs nav-pills flex-column flex-sm-row text-center bg-light border-0 rounded-nav">
<li class="nav-item flex-sm-fill">
<a id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true" class="nav-link border-0 text-uppercase font-weight-bold active">COMPOSE</a>
</li>
<li class="nav-item flex-sm-fill">
<a id="profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false" class="nav-link border-0 text-uppercase font-weight-bold">FILE UPLOAD</a>
</li>
<li class="nav-item flex-sm-fill">
<a id="contact-tab" data-toggle="tab" href="#contact" role="tab" aria-controls="contact" aria-selected="false" class="nav-link border-0 text-uppercase font-weight-bold">SCAN & UPLOAD</a>
</li>
</ul>
<div id="myTabContent" class="tab-content">
<div id="home" role="tabpanel" aria-labelledby="home-tab" class="tab-pane fade px-4 py-5 show active">
<div id="editor" class="tinymce">
<form method='post' id='compose' name='compose' class="needs-validation" action='convertandupload.php' >
<!-- hidden fields-->
<input type='hidden' id="uid" name="uid" value='<?php echo $userID;?>'>
<input type='hidden' id="path" name="path" value='<?php echo $curr_directory;?>'>
<input type='hidden' id="desc" name="desc" value='<?php echo $fileDesc;?>'>
<input type='hidden' id="fileno" name="fileno" value='<?php echo $fileNo;?>'>
<!-- end hidden fields-->
<div class='row'>
<div class='col-3'><strong>Subject</strong></div>
<div class ='col-9'><input type='text' class='form-control' id ='subject' name='subject' required></div>
</div>
<div class="clearfix"> .</div>
<textarea id="mytextarea" name="mytextarea" rows="55"></textarea>
<div class='row bg-dark text-white pt-2 pb-2 rounded'>
<br>
<div class='col-3'>
<strong>Document Name: </strong>
</div>
<div class='col-6'>
<input type='text' class="form-control" id="docname" name="docname" required>
</div>
<div class='col-3'>
<button class="btn btn-info" id='btnAddNewDoc' name ='btnAddNewDoc' type="submit"><small><strong> Upload</strong><span aria-hidden="true" class="spinner-border spinner-border-sm" id="add-NewFile-spinner" role="status" style="display: none;"></span></small></button>
</div>
<br>
<div id="server-results">
<!-- For server results -->
</div>
</div>
</form>
</div>
</div>
<div id="profile" role="tabpanel" aria-labelledby="profile-tab" class="tab-pane fade px-4 py-5">
<div class='row'>
<div class='col-8'>
<input type='hidden' id="path1" name="path1" value='<?php echo __DIR__.$curr_directory;?>'>
<input type='hidden' id="user1" name="user1" value='<?php echo $_SESSION['user'];?>'>
<input type='hidden' id="file1" name="file1" value='<?php echo $fileNo;?>'>
<div id='extraupload'></div>
<input type='button' id='extrabutton' value='upload'>
</div>
<div class='col-4'>
<div id='eventsmessage'></div>
</div>
</div>
</div>
<div id="contact" role="tabpanel" aria-labelledby="contact-tab" class="tab-pane fade px-4 py-5">
<i class="large material-icons">mood_bad</i>
<p>This feature will be included in the upcoming version</p>
</div>
<!-- End rounded tabs -->
</div>
<!-------------------------------------------------------------end add document--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function() {
$('.btn-popup').click(function () {
var fileID = $(this).data('id');
var reviewer= $(this).data('reviewer');
//alert(fileID);
$.ajax({
url: 'fetchNotesheet.php',
type: 'post',
data: { file: fileID},
success: function (response) {
$('.modal-body').html(response);
$('#notesheetModal').modal('show');
}
});
});
$('.btn-remark').click(function () {
var fileID = $(this).data('id');
var reviewer= $(this).data('reviewer');
//alert(fileID);
$.ajax({
url: 'fetchRemark.php',
type: 'post',
data: { file: fileID},
success: function (response) {
$('.modal-body').html(response);
$('#notesheetModal').modal('show');
}
});
});
$("#myBtn3").click(function(){
$("#myModal3").modal({backdrop: "static"});
})
});

Why isn't this navigation menu working properly?

This is a bootstrap navigation menu which is placed above the main menu (fixed), I'm not sure what the problem exactly is! I want it to be in one row.
This is the fixed-top navbar:
and this is how the navbar that I want it to be above it looks, it covers the fixed-top navbar and it doesn't show properly:
Below is the navigation menu code:
<nav class="navbar justify-content-between">
<ul class="nav navbar-nav navbar-right">
<li>
<p class="navbar-text">Already have an account?</p>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><b>Login</b><span class="caret"></span>
</a>
<ul id="login-dp" class="dropdown-menu">
<li>
<div class="row">
<div class="col-md-12">Login
<form class="form" role="form" method="post" action="login" accept-charset="UTF-8" id="login-nav">
<div class="form-group">
<label class="sr-only" for="exampleInputEmail2">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail2" placeholder="Email address" required>
</div>
<div class="form-group">
<label class="sr-only" for="exampleInputPassword2">Password</label>
<input type="password" class="form-control" id="exampleInputPassword2" placeholder="Password" required>
<div class="help-block text-right">
Forget the password ?
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-block">Sign in</button>
</div>
<div class="checkbox">
<label>
<input type="checkbox"> keep me logged-in
</label>
</div>
</form>
</div>
<div class="bottom text-center">New here ? <b>Join Us</b>
</div>
</div>
</li>
</ul>
</li>
</ul>
</nav>
I appreciate your help.
CSS
img{
width: 100%;
height: 500px;
}
.dropdown-menu{
background-color: #49f357;
}
.dropdown-menu{
right: 0 !important;
}
.dropdown-toggle{
background-color:#2de03c;
}
.dropdown-toggle > .active { color: aqua;}
.dropdown-toggle:hover {background-color: #0eb41c;}
.dropdown-menu > .active > a,.dropdown-menu > .active > a:hover.dropdown-menu > .active > a:focus {color: white!important; background-color: #e7e7e7!important;}
.dropdown-item{
background-color: #2de03c;
}
.dropdown-menu-center {
left: 50% !important;
right: auto !important;
text-align: center !important;
transform: translate(-50%, 0) !important;
}
.textwhite{
color:white ;
}
.collapse ul.navbar-nav> .nav-item > a {
color: white;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
}
.nav-collapse.collapse {
display: none !important;
height: auto !important;
overflow: visible !important;
}
.navbar{
position: sticky
}
HTML
<div class="d-none d-xl-block p-0">
<nav class=" navbar navbar-expand-md navbar-dark fixed-top" style="background-color: #10c720;">
<a class="navbar-brand" href="#">Brand</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExample04"
aria-controls="navbarsExample04" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse mb-2" id="navbarsExample04">
<ul class="navbar-nav">
<li class="nav-item active" style="margin-left: 150px;">
<a routerLink="/Home" class="nav-link ml-2 mt-2 mr-2 fontsize" href="#">HOME <span
class="sr-only">(current)</span></a>
</li>
<li class="nav-item ml-2 mt-2 mr-2">
<a routerLink="/About" class="nav-link fontsize">ABOUT</a>
</li>
<li *ngIf='isMale' class="nav-item ml-2 mt-2">
<a routerLink="/Bride" class="nav-link fontsize">ABOUT</a>
</li>
<li *ngIf='isFemale' class="nav-item ml-2 mt-2">
<li class="nav-item ml-2 mt-2 mr-2">
<a routerLink="/Contact" class="nav-link fontsize">CONTACT</a>
</li>
</ul>
<div class="dropdown text-center border border-danger ">
<button class="btn btn-success dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
Login
</button>
<div class="row border border-primary">
<div class="dropdown-menu dropdown-menu-center border border-danger" aria-labelledby="dropdownMenuButton">
<div class="">Login
<form class="form" role="form" method="post" action="login" accept-charset="UTF-8" id="login-nav">
<div class="form-group">
<label class="sr-only" for="exampleInputEmail2">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail2" placeholder="Email address"
required>
</div>
<div class="form-group">
<label class="sr-only" for="exampleInputPassword2">Password</label>
<input type="password" class="form-control" id="exampleInputPassword2" placeholder="Password"
required>
<div class="help-block text-right">
Forget the password ?
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-block">Sign in</button>
</div>
<div class="checkbox">
<label>
<input type="checkbox"> keep me logged-in
</label>
</div>
</form>
</div>
<div class="bottom text-center">New here ? <b>Join Us</b>
</div>
</div>
</div>
</div>
</div>
</nav>
</div>
Output

Condition to display the modal bootstrap

How can I, if I not fill the line in "origin" or "destination" input, and after I click the "Book" button, the modal won't display and it's will show other modal that require me to fill it.
At me, when I not fill the contain in the input, it's still show that I can book. And not tell me to fill it. So How can I to do it.
Thanks.
https://i.imgur.com/undefined.png
<div class="containermap">
<div class="column">
<div class="col-md-6">
<form id="distance_form">
<div class="form-group"><label>Origin: </label> <input class="form-control" id="from_places" placeholder="Enter a location" /> <input id="origin" name="origin" required="" type="hidden" /></div>
<div class="form-group"><label>Destination: </label> <input class="form-control" id="to_places" placeholder="Enter a location" /> <input id="destination" name="destination" required="" type="hidden" /></div>
<input class="btn btn-primary" type="submit" value="Calculate" /></form>
<div id="result">
<ul class="list-group">
<form id="distance_form">
<li class="list-group-item d-flex justify-content-between align-items-center">
Distance in Kilometer:
<span id='in_Kilometer' class="badge badge-primary badge-pill"></span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
Duration(min):
<span id="duration_text" class="badge badge-primary badge-pill"></span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
FROM:
<span id="from" class="badge badge-primary badge-pill"></span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
TO:
<span id="to" class="badge badge-primary badge-pill"></span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
COST(VND):
<span id="cost" class="badge badge-primary badge-pill"></span>
</li>
</ul>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#ModalLong">
BOOK
</button>
</form>
</div>
</div>
<div id="map"></div>
</div>
<div class="modal fade indexmap" id="ModalLong" tabindex="-1" role="dialog" aria-labelledby="ModalTitle" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="ModalTitle">Booking Information</h5>
<button type="button" class="Cancel" data-dismiss="modal" aria-label="Cancel">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Do you want to book now?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#ModalLong2" data-dismiss="modal">Continue</button>
</div>
</div>
</div>
</div>
<div class="modal fade indexmap" id="ModalLong2" tabindex="-1" role="dialog" aria-labelledby="ModalTitle2" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="ModalTitle2">Booking Information</h5>
<button type="button" class="Cancel" data-dismiss="modal" aria-label="Cancel">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Booking successfully! </p>
<p>Your driver will come soon. Thank you for using our services. <p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
</div>
Here is the code we made some changes to your html code and add some jquery code
remember if you have bootstrap and jquery already included then remove these links
After origin and destination form submitted you have to show the result in distance and kilometer section and you can show the book form by this jquery function
$("#result).show();
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="containermap">
<div class="column">
<div class="col-md-6">
<form id="distance_form">
<div class="form-group"><label>Origin: </label> <input class="form-control" id="from_places" placeholder="Enter a location" />
<input id="origin" name="origin" required="" type="hidden" />
</div>
<div class="form-group"><label>Destination: </label> <input class="form-control" id="to_places" placeholder="Enter a location" />
<input id="destination" name="destination" required="" type="hidden" /></div>
<input class="btn btn-primary" type="submit" value="Calculate" />
</form>
<div id="result">
<ul class="list-group">
<form id="distance-result">
<li class="list-group-item d-flex justify-content-between align-items-center">
Distance in Kilometer:
<span id='in_Kilometer' class="badge badge-primary badge-pill"></span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
Duration(min):
<span id="duration_text" class="badge badge-primary badge-pill"></span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
FROM:
<span id="from" class="badge badge-primary badge-pill"></span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
TO:
<span id="to" class="badge badge-primary badge-pill"></span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
COST(VND):
<span id="cost" class="badge badge-primary badge-pill"></span>
</li>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#ModalLong">
BOOK
</button>
</form>
</ul>
</div>
</div>
<div id="map"></div>
</div>
<div class="modal fade indexmap" id="ModalLong" tabindex="-1" role="dialog" aria-labelledby="ModalTitle" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="ModalTitle">Booking Information</h5>
<button type="button" class="Cancel" data-dismiss="modal" aria-label="Cancel">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Do you want to book now?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#ModalLong2" data-dismiss="modal">Continue</button>
</div>
</div>
</div>
</div>
<div class="modal fade indexmap" id="ModalLong2" tabindex="-1" role="dialog" aria-labelledby="ModalTitle2" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="ModalTitle2">Booking Information</h5>
<button type="button" class="Cancel" data-dismiss="modal" aria-label="Cancel">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Booking successfully! </p>
<p>Your driver will come soon. Thank you for using our services. <p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$("#result").hide();
});
$("#distance_form").submit(function(e){
var origin = $("#from_places").val();
var destination = $("#to_places").val();
if(origin == "" || destination == ""){
e.preventDefault();
alert("Origin and destination field are required");
}else{
$("#distance_form").submit();
}
});
</script>

Modal box is not working inside navbar tabs (bootstrap)

I have been trying a lot of times but still no use i am not able to display my modal in the navbar tabs. When i click on it a blur is triggered. Can someone please help me?
MY Template,
addnewrecord() {
$('#editmodel').modal('show');
}
<div class="col-xs-12">
<div class="row">
<div class="col-xs-12">
<div class="tabbable tabs-left mb-lg">
<ul id="tabs2" class="nav nav-tabs">
<li class="nav-item"><a class="nav-link" href="#tab1" data-toggle="tab">Home</a>
</li>
<li class="nav-item"><a class="nav-link active" [routerLink]="['/app/tables/basic']" data-toggle="tab">Chatter</a>
</li>
</ul>
<div id="tabs2c" class="tab-content bg-info-light">
<div class="tab-pane active">
<div class="page-title">
<div class="btn-group">
<button class="btn btn-sm btn-default" (click)='addnewrecord()'>
New
</button>
</div>
</div>
<div class="modal fade" id="editmodel" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<div class="modal-body">
<form id='form' class="form-horizontal form-label-left parsleyjs" method="post" data-parsley-priority-enabled="false" novalidate="novalidate">
<div class="form-group">
<label for="email">FirstName:</label>
<input type="text" [(ngModel)]='student.accountname' name='accountname' class="form-control" id="email" placeholder="Enter Firstname" required='required'>
</div>
<button type="submit" class="btn btn-primary" (click)='insertdata(student,student._id)'>{{buttonname}}</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" (click)='resetform()'>Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Please try this code,
$('#editmodel').show();

Navbar doesn't collapse quite right

I have a navbar that looks like this:
When I try and shrink the page to simulate a mobile device however, it doesn't collapse quite right:
It's supposed to collapse so that the button that is sort of hidden behind the "Register" text becomes the toggle for the menu. Here is my code:
<div class="sticky-header-navbar-container">
<div class="well">
<div class="navbar navbar-default navbar-fixed-top navbar-collapse navHeaderCollapse" id="navbar">
<button class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse">
<span class="icon-bar">Home</span>
<span class="icon-bar">About</span>
<span class="icon-bar">Contact</span>
<span class="icon-bar">Playground</span>
<span class="icon-bar">Login</span>
<span class="icon-bar"><a href="#" class="tooltip-bottom" data-toggle="modal" data-target="#registration-modal"
data-tooltip="Only Required to Comment and Rate!">Want to Register? Click Here!</a></span>
</button>
<ul class="nav navbar-nav">
<li>
Home
</li>
<li>
About
</li>
<li>
Contact
</li>
<li>
Playground
</li>
<li>
<form class="navbar-form" role="search">
<div class="input-group" style="width: 100%">
<input type="text" class="form-control" placeholder="Search" name="srch-term" id="srch-term-header">
<div class="input-group-btn">
<button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span></button>
</div>
</div>
</form>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
Login
</li>
<li style="padding-right: 20px">
<a href="#" class="tooltip-bottom" data-toggle="modal" data-target="#registration-modal"
data-tooltip="Only Required to Comment and Rate!">Want to Register? Click Here!</a>
</li>
</ul>
</div>
</div>
</div>
<div id="about-modal" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">About This Page</h4>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger btn-bg" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="contact-modal" class="modal fade" role="dialog">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Contact Us!</h4>
</div>
<div class="modal-body">
<p>Got any Feedback (Positive and/or Negative) or any ideas? Please let us know!</p>
<p>Your email is only used to contact you back with an answer. We will never spam your email (Promise!)</p>
<div class="form-group">
<form role="form">
<div class="form-group">
<label for="contact-name" class="sr-only">Your Name</label>
<input type="text" id="contact-name" class="form-control" placeholder="Your Name" required>
</div>
<div class="form-group">
<label for="contact-email" class="sr-only">Your Email</label>
<input type="email" id="contact-email" class="form-control" placeholder="Your Email" required>
</div>
<div class="form-group">
<textarea id="contact-message" class="form-control" rows="6" cols="50" placeholder="Your message..." required></textarea>
</div>
<button type="button" class="btn btn-success btn-bg" id="contact-submit-btn"><span>Submit</span></button>
</form>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger btn-bg" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="login-modal" class="modal fade" role="dialog">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Login with Github!</h4>
</div>
<div class="modal-body">
<form class="navbar-form">
<label for="login-inputEmail" class="sr-only">Email address</label>
<input type="email" id="login-inputEmail" class="form-control" placeholder="Email Address" required>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
<div class="separator" style="padding-bottom: 15px"></div>
<div class="checkbox" style="padding-right: 15px;padding-left: 10px">
<label>
<input type="checkbox" value="remember-me">
Remember Me
</label>
</div>
<button type="button" class="btn btn-success btn-bg" id="signin-btn"><span class="glyphicon glyphicon-log-in"></span></button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger btn-bg" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="registration-modal" class="modal fade" role="dialog">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">How To Register</h4>
</div>
<div class="modal-body">
<p>In order to log in you need a Github account as we use that for log in here.</p>
<p>If you already registered for a Github account then press the Login button and log in using your Github Credentials.</p>
<p>If you have yet to register Click Here!</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger btn-bg" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
If that's all the related code then you shouldn't need anything outside the default classes.
See Default Navbar Docs.
You shouldn't need these modal links in the header and then again within the navbars links, these are whats covering up the mobile toggle button.
And your HTML structure is off and/or missing some pieces. Again if you refer to the Docs you'll see the inconsistencies, you need to put your toggle button inside the navbar-header class, navbar-form does not belong inside of a li item etc.
See working example Snippet.
*Note that because you links that utilize a lot of space at around 875px you'll see your navbar overflow to a new line (a CSS media query turns the background red when this happens in my example). One solution is to reduce the length of the link title(s) to prevent this:
ie Want to Register? Click Here! to just Register!.
#media (max-width: 875px) {
html,
body {
background: red;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navHeaderCollapse" aria-expanded="false"> <span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse navHeaderCollapse">
<ul class="nav navbar-nav">
<li> Home
</li>
<li> About
</li>
<li> Contact
</li>
<li> Playground
</li>
</ul>
<form class="navbar-form navbar-left" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="srch-term" id="srch-term-header"> <span class="input-group-btn">
<button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
</form>
<ul class="nav navbar-nav navbar-right">
<li> Login
</li>
<li> Want to Register? Click Here!
</li>
</ul>
</div>
</div>
</nav>
<div id="about-modal" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">About This Page</h4>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button type="button" class="btn btn-danger btn-bg" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="contact-modal" class="modal fade" role="dialog">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Contact Us!</h4>
</div>
<div class="modal-body">
<p>Got any Feedback (Positive and/or Negative) or any ideas? Please let us know!</p>
<p>Your email is only used to contact you back with an answer. We will never spam your email (Promise!)</p>
<div class="form-group">
<form role="form">
<div class="form-group">
<label for="contact-name" class="sr-only">Your Name</label>
<input type="text" id="contact-name" class="form-control" placeholder="Your Name" required>
</div>
<div class="form-group">
<label for="contact-email" class="sr-only">Your Email</label>
<input type="email" id="contact-email" class="form-control" placeholder="Your Email" required>
</div>
<div class="form-group">
<textarea id="contact-message" class="form-control" rows="6" cols="50" placeholder="Your message..." required></textarea>
</div>
<button type="button" class="btn btn-success btn-bg" id="contact-submit-btn"><span>Submit</span>
</button>
</form>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger btn-bg" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="login-modal" class="modal fade" role="dialog">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Login with Github!</h4>
</div>
<div class="modal-body">
<form class="navbar-form">
<label for="login-inputEmail" class="sr-only">Email address</label>
<input type="email" id="login-inputEmail" class="form-control" placeholder="Email Address" required>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
<div class="separator" style="padding-bottom: 15px"></div>
<div class="checkbox" style="padding-right: 15px;padding-left: 10px">
<label>
<input type="checkbox" value="remember-me">Remember Me</label>
</div>
<button type="button" class="btn btn-success btn-bg" id="signin-btn"><span class="glyphicon glyphicon-log-in"></span>
</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger btn-bg" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="registration-modal" class="modal fade" role="dialog">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">How To Register</h4>
</div>
<div class="modal-body">
<p>In order to log in you need a Github account as we use that for log in here.</p>
<p>If you already registered for a Github account then press the Login button and log in using your Github Credentials.</p>
<p>If you have yet to register Click Here!
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger btn-bg" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>