switching bootstrap tab by click - php

I want to next tab only by button click.
This is my file aspirante.php that contains tab panel:
<div class="bs-example bs-example-tabs" role="tabpanel">
<ul id="myTab" class="nav nav-tabs" role="tablist">
<li role="presentation" class="active">Aspirante</li>
<li role="presentation">Domicilios</li>
<li role="presentation">Inform. Académica</li>
<li role="presentation">Inform. Adicional</li>
<li role="presentation">Finalizar</li>
</ul>
<br>
<div id="myTabContent" class="tab-content" >
include_once('aspiranteForm.php');
include_once('aspiranteDomicilioForm.php');
include_once('aspiranteInformacionAcademicaForm.php');
include_once('aspiranteAdicionalForm.php');
include_once('aspiranteTramiteCerrarForm.php');
</div>
<script>
$('.nav li a').click(function(e) {
e.preventDefault();
return false;
});
</script>
Example aspiranteForm:
<div role="tabpanel" class="tab-pane fade in active" id="aspirante" aria-labelledBy="aspirante-tab">
<form id="aspiranteForm" name="aspiranteForm" method="post" enctype="multipart/form-data" action="aspirante.php" >
<div class="row">
<div class="form-group col-md-12">
<button id="submitAspitante" type="submit" class="btn btn-primary">Save</button>
<button id="submitAspitante2" type="submit" class="btn btn-primary" onclick="$('li').removeClass('active');$('#domicilio-li').addClass('active');$('.nav-tabs > .active').next('li').find('a').trigger('click');">Save & Continue</button>
</div>
</div>
</form>
</div>
I want for default that all tabs are "no active", only the current tab is active.
When I clicked button submit (id="submitAspirante2") send data for post and next tab. Actually when I clicked no next tab.
Thank you.

First of all you dont need that script.
<div class="bs-example bs-example-tabs" role="tabpanel">
<ul id="myTab" class="nav nav-tabs" role="tablist">
<li role="presentation" class="active">Aspirante</li>
<li role="presentation"><a href="#domicilios-tab" aria-controls="domicilios-tab" role="tab" data-toggle="tab" aria-expanded="true" >Domicilios</a></li>
<li role="presentation"><a href="#academica-tab" aria-controls="aspirante-tab" role="tab" data-toggle="tab" aria-expanded="true" >Inform. Académica</a></li>
<li role="presentation">Inform. Adicional</li>
<li role="presentation">Finalizar</li>
</ul><br>
<div id="myTabContent" class="tab-content" >
include('aspiranteForm.php');
include('aspiranteDomicilioForm.php');
include('aspiranteInformacionAcademicaForm.php');
include('aspiranteAdicionalForm.php');
include('aspiranteTramiteCerrarForm.php');
</div>
Then your first active Forms should be like this
<div class="tab-pane fade in active" id="aspirante-tab">
<form id="aspiranteForm" name="aspiranteForm" method="post" enctype="multipart/form-data" action="aspirante.php" >
<div class="row">
<div class="form-group col-md-12">
<button id="submitAspitante" type="submit" class="btn btn-primary">Save</button>
<button id="submitAspitante2" type="submit" class="btn btn-primary" onclick="$('li').removeClass('active');$('#domicilio-li').addClass('active');$('.nav-tabs > .active').next('li').find('a').trigger('click');">Save & Continue</button>
</div>
</div>
Then the other inactive forms should be like this
<div class="tab-pane" id="domicilios-tab">
<form id="aspiranteForm" name="aspiranteForm" method="post" enctype="multipart/form-data" action="aspirante.php" >
<div class="row">
<div class="form-group col-md-12">
domicilios
<button id="submitAspitante" type="submit" class="btn btn-primary">Save</button>
<button id="submitAspitante2" type="submit" class="btn btn-primary" onclick="$('li').removeClass('active');$('#domicilio-li').addClass('active');$('.nav-tabs > .active').next('li').find('a').trigger('click');">Save & Continue</button>
</div>
</div>
More refference in here

Related

Bootstrap 5 - form multi step wizard - validation one page at a time

I have a problem with my multi step form. Whenever I click the "next" button, instead of just the current tab being validated, it validates all the tabs on the form. How can I do to just validate only the current TAB?
If I have a form in each TAB, the validation will work as I want, but then I can't submit all forms at once.
index.php
<div id="rootwizard">
<ul class="nav nav-pills form-wizard-header mb-3">
<li class="nav-item" data-target-form="#one">
<a href="#basic" data-bs-toggle="tab" data-toggle="tab" class="nav-link rounded-0 pt-2 pb-2">
<span>Info</span>
</a>
</li>
<li class="nav-item" data-target-form="#two">
<a href="#first" data-bs-toggle="tab" data-toggle="tab" class="nav-link rounded-0 pt-2 pb-2">
<span>Device</span>
</a>
</li>
</ul>
<div>
<div id="basic">
<form id="one" method="post" action="" class="form-horizontal">
<div class="row mb-3">
<label for="Client_Emp">Cliente/Empresa</label>
<div>
<input type="text" name="Client_Emp" id="Client_Emp" required />
</div>
</div>
</form>
</div>
<div class="tab-pane" id="first">
<form id="two" method="post" action="" class="form-horizontal">
<div class="row mb-3">
<label for="cpu">CPU</label>
<div>
<input type="text" name="cpu" id="Client_Emp" required />
<option></option>
</select>
</div>
</div>
</form>
</div>
<ul class="list-inline wizard mb-0">
<li class="previous list-inline-item">Previous
</li>
<li class="next list-inline-item float-end">Next</li>
</ul>
</div> <!-- tab-content -->
</div> <!-- end #rootwizard-->
Thanks. I managed to solve it with this javascript.
$("#global").submit(function(e) {
var $ch1 = $("#form_info").children();
var $ch2 = $("#form_first").children();
var $ch3 = $("#form_second").children();
var $ch4 = $("#form_third").children();
var $ch5 = $("#form_fourth").children();
var $ch6 = $("#form_fifth").children();
$(this).append($ch1).append($ch2).append($ch3).append($ch4).append($ch5).append($ch6);
$("#global").submit();
});

Second tab not showing in form boostrap

This my code
I have a form with bootstrap and 2 tabs, when I display the form shows the first tab, but when I click on the second tab nothing happens.
I dont know what I missing.......................................
...............................................................
<div class="container" style="margin-top:70px">
<div class ="card bg-light col-8">
<div class="card-header">
<ul class="nav nav-tabs card-header-tabs pull-left">
<li class="nav-item">
<a class="nav-link active" href="#contactos">Contactos</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#domicilio">Domicilio</a>
</li>
</ul>
</div>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"])."?opc=".$opc."&id=".$id;?>" method="post" id ="formulario" class="tab-content">
<div class="tab-pane fade show active" id="contactos">
<div class="form-row" > <!--linea1-->
<div class="col-3">
<div class="form-group">
<label for="text1">ID</label>
<input id="text1" name="text1" type="text" class="form-control" value="<?php echo $campo1?>" readonly>
</div>
</div>
</div> <!--linea1-->
</div> <!--tab contacto-->
<div class="tab-pane fade" id="domicilio">
<div class="form-row" > <!--linea5-->
<div class="col">
<div class="form-group">
<label for="text11">Calle</label>
<input id="text11" name="text11" type="text" class="form-control" value="<?php echo $campo11?>" required <?php if ($opc == 'C'){echo "readonly";}?>>
<span class="error"><?php echo $error_text11;?></span>
</div>
</div>
</div> <!--linea5-->
</div> <!--tab domicilio-->
<div class="form-row"> <!--linea9-->
<div class="col-6">
<div class="form-group">
Cancelar
<button name="submit" type="submit" class="btn btn-primary">Confirmar</button>
</div>
</div>
</div> <!--linea9-->
</form>
</div>
</div>
for bootstrap 5 as per docs you need to add data-bs-toggle="tab" data-bs-target="#{tabID}" type="button" role="tab" aria-controls="{tabID}" aria-selected="true" to the a tag with class nav-link
so your code should be
<div class="container" style="margin-top:70px">
<div class ="card bg-light col-8">
<div class="card-header">
<ul class="nav nav-tabs card-header-tabs pull-left">
<li class="nav-item">
<a class="nav-link active" href="#contactos" data-bs-toggle="tab" data-bs-target="#contactos" type="button" role="tab" aria-controls="contactos" aria-selected="true">Contactos</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#domicilio" data-bs-toggle="tab" data-bs-target="#domicilio" type="button" role="tab" aria-controls="domicilio" aria-selected="true">Domicilio</a>
</li>
</ul>
</div>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"])."?opc=".$opc."&id=".$id;?>" method="post" id ="formulario" class="tab-content">
<div class="tab-pane fade show active" id="contactos">
<div class="form-row" > <!--linea1-->
<div class="col-3">
<div class="form-group">
<label for="text1">ID</label>
<input id="text1" name="text1" type="text" class="form-control" value="<?php echo $campo1?>" readonly>
</div>
</div>
</div> <!--linea1-->
</div> <!--tab contacto-->
<div class="tab-pane fade" id="domicilio">
<div class="form-row" > <!--linea5-->
<div class="col">
<div class="form-group">
<label for="text11">Calle</label>
<input id="text11" name="text11" type="text" class="form-control" value="<?php echo $campo11?>" required <?php if ($opc == 'C'){echo "readonly";}?>>
<span class="error"><?php echo $error_text11;?></span>
</div>
</div>
</div> <!--linea5-->
</div> <!--tab domicilio-->
<div class="form-row"> <!--linea9-->
<div class="col-6">
<div class="form-group">
Cancelar
<button name="submit" type="submit" class="btn btn-primary">Confirmar</button>
</div>
</div>
</div> <!--linea9-->
</form>
</div>
</div>
working example JSfiddle
Edit:
if you are using bootstrap 4 just remove -bs from the data attributes so it would be data-toggle="tab" data-target="#{tabID}" type="button" role="tab" aria-controls="{tabID}" aria-selected="true"
<div class="container" style="margin-top:70px">
<div class ="card bg-light col-8">
<div class="card-header">
<ul class="nav nav-tabs card-header-tabs pull-left">
<li class="nav-item">
<a class="nav-link active" href="#contactos" data-toggle="tab" data-target="#contactos" type="button" role="tab" aria-controls="contactos" aria-selected="true">Contactos</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#domicilio" data-toggle="tab" data-target="#domicilio" type="button" role="tab" aria-controls="domicilio" aria-selected="true">Domicilio</a>
</li>
</ul>
</div>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"])."?opc=".$opc."&id=".$id;?>" method="post" id ="formulario" class="tab-content">
<div class="tab-pane fade show active" id="contactos">
<div class="form-row" > <!--linea1-->
<div class="col-3">
<div class="form-group">
<label for="text1">ID</label>
<input id="text1" name="text1" type="text" class="form-control" value="<?php echo $campo1?>" readonly>
</div>
</div>
</div> <!--linea1-->
</div> <!--tab contacto-->
<div class="tab-pane fade" id="domicilio">
<div class="form-row" > <!--linea5-->
<div class="col">
<div class="form-group">
<label for="text11">Calle</label>
<input id="text11" name="text11" type="text" class="form-control" value="<?php echo $campo11?>" required <?php if ($opc == 'C'){echo "readonly";}?>>
<span class="error"><?php echo $error_text11;?></span>
</div>
</div>
</div> <!--linea5-->
</div> <!--tab domicilio-->
<div class="form-row"> <!--linea9-->
<div class="col-6">
<div class="form-group">
Cancelar
<button name="submit" type="submit" class="btn btn-primary">Confirmar</button>
</div>
</div>
</div> <!--linea9-->
</form>
</div>
</div>
working fiddle for bootstrap 4

How do I dynamically populate modal from PHP server side product data?

I am retrieving some products from the database using PHP and MySQL. I am displaying these products in a carousel. When the user hovers, a "Show Quick Details" button will appear.
When the user clicks that button, a modal shows up displaying the product details.
Example:
Here is the modal when the user clicks.... (no, the products don't match right now, I am using a template the client gave me with example images ).
User Clicks Button:
My question is, how do I go about populating the modal with the correct product information? Do I have to create 10 modals dynamically in my PHP , or is there a better route? I am kinda stumped on how to approach this.
Here is the modal I am using, in case that is helpful for an answer:
<!--====== Quick View Part Start ======-->
<!-- Modal -->
<div class="modal fade " id="productQuickModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<i class="fal fa-times"></i>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-6">
<div class="product-quick-view-image mt-30">
<div class="quick-view-image">
<div class="single-view-image">
<img src="images/product-17.jpg" alt="product">
</div>
<div class="single-view-image">
<img src="images/product-18.jpg" alt="product">
</div>
<div class="single-view-image">
<img src="images/product-19.jpg" alt="product">
</div>
<div class="single-view-image">
<img src="images/product-20.jpg" alt="product">
</div>
<div class="single-view-image">
<img src="images/product-21.jpg" alt="product">
</div>
</div>
<ul class="quick-view-thumb">
<li>
<div class="single-thumb">
<img src="images/product-17.jpg" alt="">
</div>
</li>
<li>
<div class="single-thumb">
<img src="images/product-18.jpg" alt="">
</div>
</li>
<li>
<div class="single-thumb">
<img src="images/product-19.jpg" alt="">
</div>
</li>
<li>
<div class="single-thumb">
<img src="images/product-20.jpg" alt="">
</div>
</li>
<li>
<div class="single-thumb">
<img src="images/product-21.jpg" alt="">
</div>
</li>
</ul>
</div> <!-- Modal Quick View Image -->
</div>
<div class="col-md-6">
<div class="product-quick-view-content mt-30">
<h3 class="product-title">Trans-Weight Hooded Wind and Water Resistant Shell</h3>
<p class="reference">Reference: demo_12</p>
<ul class="rating">
<li class="rating-on"><i class="fas fa-star"></i></li>
<li class="rating-on"><i class="fas fa-star"></i></li>
<li class="rating-on"><i class="fas fa-star"></i></li>
<li class="rating-on"><i class="fas fa-star"></i></li>
<li class="rating-on"><i class="fas fa-star"></i></li>
</ul>
<div class="product-prices">
<span class="sale-price"> €23.90</span>
<span class="regular-price">€21.03</span>
<span class="save">Save 12%</span>
</div>
<p class="product-description">Block out the haters with the fresh adidas® Originals Kaval Windbreaker Jacket. <br> Part of the Kaval Collection. <br> Regular fit is eased, but not sloppy, and perfect for any activity. <br> Plain-woven jacket specifically constructed for freedom of movement.</p>
<div class="product-size-color flex-wrap">
<div class="product-size">
<h5 class="title">Size</h5>
<select>
<option value="1">S</option>
<option value="2">M</option>
<option value="3">L</option>
<option value="4">XL</option>
</select>
</div>
<div class="product-color">
<h5 class="title">Color</h5>
<div class="color-input">
<div class="single-color color-1">
<input type="radio" id="radio-1" name="color">
<label for="radio-1"></label>
</div>
<div class="single-color color-2">
<input type="radio" id="radio-2" name="color">
<label for="radio-2"></label>
</div>
<div class="single-color color-3">
<input type="radio" id="radio-3" name="color">
<label for="radio-3"></label>
</div>
</div>
</div>
<div class="product-quantity">
<h5 class="title">Quantity</h5>
<div class="quantity d-flex">
<button type="button" id="sub" class="sub"><i class="fal fa-minus"></i></button>
<input type="text" value="1" />
<button type="button" id="add" class="add"><i class="fal fa-plus"></i></button>
</div>
</div>
</div>
<div class="product-add-cart">
<button><i class="icon ion-bag"></i> Add to cart</button>
</div>
<div class="product-wishlist-compare">
<ul class="d-flex flex-wrap">
<li><i class="fal fa-heart"></i> Add to wishlist</li>
<li><i class="fal fa-repeat"></i> Add to compare</li>
</ul>
</div>
<div class="product-share d-flex">
<p>Share</p>
<ul class="social media-body">
<li><i class="fab fa-facebook-f"></i></li>
<li><i class="fab fa-twitter"></i></li>
<li><i class="fab fa-google"></i></li>
<li><i class="fab fa-pinterest-p"></i></li>
</ul>
</div>
</div> <!-- Modal Quick View Content -->
</div>
</div> <!-- row -->
</div> <!-- Modal Body -->
</div> <!-- Modal content -->
</div> <!-- Modal dialog -->
</div> <!-- Modal -->
Any easier ways other than creating x number of modals?
Thank you

How to submit my form without reloading page?

I need to save my form without reloading the page, I have tried all the methods...but I'm beginner at Ajax and I can't figure it out how to do that.
Here is the most relevant link, but when I press submit button, doesn't working.
How to send data without refreshing page in laravel?
My view
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog" role="document">
<div class="modal-content" style="top: 50px">
<div class="modal-header" style="border-bottom: none">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="container">
<div class="row">
<section>
<div class="wizard col-md-6" style="right: 5px;margin: 0px auto">
<div class="wizard-inner">
<div class="connecting-line"></div>
<ul class="nav nav-tabs" role="tablist" style="margin: 0px auto">
<li role="presentation" class="active">
<a href="#step1" data-toggle="tab" aria-controls="step1" role="tab" title="Step 1">
<span class="round-tab">
<i class="icon-pencil"></i>
</span>
</a>
</li>
<li role="presentation" class="disabled">
<a href="#step2" data-toggle="tab" aria-controls="step2" role="tab" title="Step 2">
<span class="round-tab">
<i class="icon-note"></i>
</span>
</a>
</li>
<li role="presentation" class="disabled">
<a href="#step3" data-toggle="tab" aria-controls="step3" role="tab" title="Step 3">
<span class="round-tab">
<i class="icon-check"></i>
</span>
</a>
</li>
</ul>
</div>
<form role="form" action="{{ action('CareerSolutionController#careerReport') }}" method="post">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="hidden" name="user_id" value="{{ Sentinel::check()->id }}">
<input type="hidden" name="user_id_posted" value="{{ $career_solution->user->id }}">
<input type="hidden" name="career_solution_id" value="{{ $career_solution->id}} ">
<div class="tab-content">
<div class="tab-pane active" role="tabpanel" id="step1">
<h3>Why are you reporting this content :</h3>
<ul style="list-style: none">
<li>
<input type="radio" id="box-9" name="why_reporting" value="Spam">
<label for="box-9">Spam</label>
<div class="check"></div>
<small id="box-9-s" style="display: none">I consider this content irrelevant and annoying.</small>
</li>
<li>
<input type="radio" id="box-10" name="why_reporting" value="Fake Profile">
<label for="box-10">Fake Profile</label>
<div class="check"><div class="inside"></div></div>
<small id="box-10-s" style="display: none">This content was posted by way of a profile that clearly doesn't represent a real person.
</small>
</li>
<li>
<input type="radio" id="box-11" name="why_reporting" value="Advertising">
<label for="box-11">Advertising</label>
<div class="check"><div class="inside"></div></div>
<small id="box-11-s" style="display: none">This content is or contains advertising.
</small>
</li>
<li>
<input type="radio" id="box-12" name="why_reporting" value="Untrustworthy source">
<label for="box-12">Untrustworthy source</label>
<div class="check"><div class="inside"></div></div>
<small id="box-12-s" style="display: none">This content is from an untrustworthy source and contains unverifiable statements.
</small>
</li>
<li>
<input type="radio" id="box-13" name="why_reporting" value="Defamatory">
<label for="box-13">Defamatory</label>
<div class="check"><div class="inside"></div></div>
<small id="box-13-s" style="display: none">The reported content is insulting or defamatory to me or other people.
</small>
</li>
<li>
<input type="radio" id="box-14" name="why_reporting" value="Violence or pornography">
<label for="box-14">Violence or pornography</label>
<div class="check"><div class="inside"></div></div>
<small id="box-14-s" style="display: none">This content contains violence or pornography.
</small>
</li>
<li>
<input type="radio" id="box-15" name="why_reporting" value="Violates IP rights">
<label for="box-15">Violates IP rights</label>
<div class="check"><div class="inside"></div></div>
<small id="box-15-s" style="display: none">This content includes third-party content (e.g. an image) posted under their own name.
</small>
</li>
<li>
<input type="radio" id="box-16" name="why_reporting" value="Promotes structural distribution measures">
<label for="box-16">Promotes structural distribution measures</label>
<div class="check"><div class="inside"></div></div>
<small id="box-16-s" style="display: none">This content promotes a chain distribution system, multilevel selling or pyramid sales.
</small>
</li>
<li >
<input type="radio" id="box-17" name="why_reporting" value="Other">
<label for="box-17" id="other">Other</label>
<div class="check"><div class="inside"></div></div>
<div class="form-group" id="mydiv" style="display: none">
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3" placeholder="Please let us know why you're reporting this content:
" style="resize: none" name="why_reporting_message"></textarea>
</div>
</li>
</ul>
<ul class="list-inline pull-right">
<li><button style="background-color: #18ba9b;border-color: white" type="button" class="btn btn-primary next-step">Save and continue</button></li>
</ul>
</div>
<div class="tab-pane" role="tabpanel" id="step2">
<h3>Why would you like to report this?</h3>
<div class="form-group">
<textarea class="form-control" id="exampleFormControlTextarea1" rows="5" style="resize: none" placeholder="
Please let us know why you're reporting this content:" name="additional_message"></textarea>
</div>
<ul class="list-inline pull-right">
<li><button type="button" class="btn btn-default prev-step">Previous</button></li>
<li><button type="button" class="btn btn-default next-step">Skip</button></li>
<li><button style="background-color: #18ba9b;border-color: white" type="button" class="btn btn-primary btn-info-full next-step" id="save">Submit your report</button></li>
</ul>
</div>
<div class="tab-pane" role="tabpanel" id="step3">
<h2 class="title-box-v2" style="font-size: 17px !important;line-height: 35px">We'll look into this as soon as possible. Thanks for helping us improve the quality of content on Workstickers.</h2>
<p style="text-align: center">You have successfully completed all steps.Flagged content and users are reviewed by Workstickers staff 24 hours a day, seven days a week to determine whether they violate Community Guidelines. Accounts are penalized for Community Guidelines violations, and serious or repeated violations can lead to account termination.
</p>
<div style="text-align: center;margin-top: 50px">If you've changed your mind - Cancel report</div>
</div>
<div class="clearfix"></div>
</div>
</form>
</div>
</section>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- END MY MODAL -->
Ajax
<script>
$(document).on("click",".save",function(){
e.preventDefault(); //Prevent page from submiting
$(document).on("click", ".save", function() {
$.ajax({
type: "post",
url: 'career_report',
data: $(".why_reporting").serialize(),
success: function(store) {
},
error: function() {
}
});
});
});
</script>
My controller
public function careerReport(requ $request)
{
$report = \App\Reports::create([
'user_id' => $request['user_id'],
'user_id_posted' => $request['user_id_posted'],
'career_solution_id' =>$request['career_solution_id'],
'why_reporting' =>$request['why_reporting'],
'why_reporting_message' =>$request['why_reporting_message'],
'additional_message' =>$request['additional_message'],
]);
if($report != ""){
flash('Career solution report submited', 'success');
}else{
flash('Career solution report', 'warning');
}
return Redirect('career_report')->with('message',"success");
}
Your event listener for the click is wrongly declared (you have an event listener declared after the first event is triggered and end up with two event listener on 'click') plus you might have a wrong url in your ajax.
try this
<script>
$('form').on("submit", function(){
e.preventDefault(); //Prevent page from submiting
var data = new FormData(this);
var url = this.action;
var method = this.method;
$.ajax({
type: method,
url: url,
data: data,
success: function(store) {
},
error: function() {
}
});
});
</script>

Modal doesn't gets focused

I was trying to use a modal. When I try to click the modal, it doesn't get focused. I'm calling the modal in the top bar navigation that is dropdown(located in the top right side). I have uploaded a photo, the link is under the code. I'm using bootstrap. I got the snippet from here
My code:
<ul class="nav navbar-right top-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Admin User <b class="fa fa-angle-down">
</b></a>
<ul class="dropdown-menu">
<!--=====HERE IS WHERE I CALL THE MODAL=====-->
<li>
<a href="#" data-toggle="modal" data-target="#changeProfile"><i class="fa fa-fw fa-cog">
</i> Change Profile</a>
</li>
<li class="divider">
</li>
<li>
<a href="#"><i class="fa fa-fw fa-power-off">
</i> Logout</a>
</li>
</ul>
</li>
</ul>
<!-- Modal Add Brand -->
<div class="modal fade" id="changeProfile" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3>
Change Profile
</h3>
</div>
<div class="modal-body">
<form class="form-horizontal" role="form">
<div class="form-group">
<label for="txtBusName" class="col-sm-2 control-label">Username</label>
<div class="col-sm-10">
<input type="text" id="txtUsername" class="form-control">
</div>
</div>
<div class="form-group">
<label for="txtBusDesc" class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<input type="password" id="txtPassword" class="form-control">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
</div>
<!-- Modal Add Brand -->
This is what it looks like. I can't click the modal at all.
Thanks!
Seems like your modal box's z-index value is lower than the half-transparent dark div that is used to "block" the page content. Try increasing your modal box's z-index value.
#changeProfile {
z-index: 9999;
}

Categories