I have the following drop-down menu in a page:
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Select a Category
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
Cat I
</li>
<li>
Cat II
</li>
<li>
Cat III
</li>
<li>
Cat IV
</li>
<li>
Cat V
</li>
</ul>
</div>
This is part of a form with POST method. How can I add the selected item to the _POST array? Should I specify a name somewhere in my code?
You can use the below method:
<form name="cat_form" id="cat_form" method="POST" />
<input class="span2" id="cat_type" name="cat_type" type="hidden">
<div>
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">Select a Category<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li onclick="$('#cat_type').val('cat_1');">Cat 1</li>
<li onclick="$('#cat_type').val('cat_2');">Cat 2</li>
<li onclick="$('#cat_type').val('cat_3');">Cat 3</li>
<li onclick="$('#cat_type').val('cat_3');">Cat 4</li>
</ul>
</div>
</form>
Use formcontrols: http://getbootstrap.com/css/#forms-controls
example:
<div class="form-group">
<label for="sel1">Category:</label>
<select class="form-control" id="sel1">
<option>Cat 1</option>
<option>Cat 2</option>
<option>Cat 3</option>
<option>Cat 4</option>
</select>
</div>
You can also overwrite the css for example:
form .form-group {
border: 2px solid red;
}
Related
Left side menu with scroll bar when click on menu link then scroll bar move not show scroll bar near to the clicked menu.
As u can see in w3schools site when clicked on side menu then scroll bar again comes on its same position on which menu we have clicked. I want same work as show by me a menu list in which tag with list item I have used scroll bar class of .scroll_text_menu
now my question is when I clicked on scroll bar menu than its goes upper side not leaves near clicked menu
Code:
.scroll_text_menu {
height: 640px;
overflow-y: scroll;
line-height: 1px;
}
<div id="sidebar-menu" class="main_menu_side hidden-print main_menu ">
<div class="menu_section">
<h3>Dashboard</h3>
<?php
$userType = $this->session->userData('userType');
?>
<ul class="nav side-menu scroll_text_menu">
<?php if ($userType == 1) { ?>
<li>
<i class="fa fa-bank"></i> Account Management
</li>
<li>
<i class="fa fa-file-text" ></i> Training Program
</li>
<?php } ?>
<?php if (in_array($userType, array("1", "2"))) { ?>
<li>
<i class="fa fa-user-md" style="font-size:19px"></i> Coach Management
</li>
<?php } ?>
<?php if (in_array($userType, array("1", "2", "3"))) { ?>
<li>
<i class="fa fa-user" ></i> Athlete Management
</li>
<li>
<i class="fa fa-users" style="font-size: 17px;"></i> Team Management
</li>
<li>
<i class="fa fa-houzz" style="font-size:20px"></i> Exercise Parent Type
</li>
<li>
<i class="fa fa-th-large" aria-hidden="true"></i> Exercise Types
</li>
<li>
<i class="fa fa-wheelchair-alt"></i> Exercise
</li>
<li>
<i class="fa fa-columns" aria-hidden="true"></i> Exercise Sets
</li>
<li>
<i class="fa fa-users" style="font-size: 17px"></i> Training Plan
</li>
<li>
<i class="fa fa-map-o" style="font-size: 17px"></i> Programs Plans
</li>
<li>
<i class="fa fa-lock" ></i> Privacy Policy
</li>
<li>
<i class="fa fa-question-circle-o" aria-hidden="true" ></i><span > Questionnaire</span>
</li>
<li>
<i class="fa fa-file-text-o"></i> User Answer
</li>
<li>
<i class="fa fa-building-o" ></i> School
</li>
<li>
<i class="fa fa-newspaper-o" aria-hidden="true" ></i> Position Title
</li>
<li>
<i class="fa fa-futbol-o" ></i> Sports
</li>
<li>
<i class="fa fa-language"></i> Languages
</li>
<?php } ?>
<?php } ?>
</ul>
</div>
</div>
I have the following html sidebar menu:
<li {{{ (Request::is('bookings/*') }}} data-toggle="collapse" data-target="#bookings">
<i class="fa fa-address-book" aria-hidden="true"></i> Bookings <i class="fa fa-chevron-down" aria-hidden="true"></i>
</li>
<ul class="sub-menu collapse" id="bookings">
<li class="collapsed">All Bookings</li>
<li class="collapsed" >Add New</li>
</ul>
<li {{{ (Request::is('bookings/*') || Request::is('bookings') ? 'class=active' : '') }}} data-toggle="collapse" data-target="#item2">
<i class="fa fa-address-book" aria-hidden="true"></i> Item 2 <i class="fa fa-chevron-down" aria-hidden="true"></i>
</li>
<ul class="sub-menu collapse" id="item2">
<li {{{ (Request::is('bookings') ? 'class=active' : 'collapsed') }}}>All Bookings</li>
<li {{{ (Request::is('bookings/create') ? 'class=active' : 'collapsed') }}} >Add New</li>
</ul>
This is a basic Bootstrap collapse menu that contains a sub menu which expands when the li element is clicked.
The problem I have is lets say I have 2 or 3 of these menu items that all have sub menus. There is a possibility that all of them could open at the same time, I don't like this because this forces a scroll overflow as the height increases which then shows a scrollbar for the side menu.
Is there a way I can prevent multiple elements from being expanded in Bootstrap?
I am using Laravel 5 if that helps.
I think this should help you, just play a little with it to adapt it to your needs:
<div class="row">
<div class="col">
<ul class="nav nav-stacked" id="accordion1">
<li class="panel"> <a data-toggle="collapse" data-parent="#accordion1" href="#firstLink">Test12</a>
<ul id="firstLink" class="collapse">
<li>SubTest1</li>
<li>SubTest1</li>
<li>SubTest1</li>
</ul>
</li>
<li class="panel"> <a data-toggle="collapse" data-parent="#accordion1" href="#secondLink">Test2</a>
<ul id="secondLink" class="collapse">
<li>SubTest2</li>
<li>SubTest2</li>
<li>SubTest2</li>
<li>SubTest2</li>
</ul>
</li>
</ul>
</div>
</div>
See it here
https://codepen.io/anon/pen/ZaMOxN
I have menu which is has sub menus.
<li>
<i class="fa fa-flag-checkered" aria-hidden="true"></i> <span>Lead</span> <i class="icon-submenu lnr lnr-chevron-left"></i>
<div id="lead" class="collapse ">
<ul class="nav">
<li><i class="fa fa-quote-right" aria-hidden="true"></i><span> Quotation </span><i class="icon-submenu lnr lnr-chevron-left"></i>
<div id="quotation" class="collapse ">
<ul class="nav">
<li><i class="fa fa-dot-circle-o" aria-hidden="true"></i> Create Quotation</li>
<li><i class="fa fa-dot-circle-o" aria-hidden="true"></i> Quotation Summary</li>
<li><i class="fa fa-dot-circle-o" aria-hidden="true"></i> Send Quotation</li>
</ul>
</div>
</li>
</ul>
</div>
</li>
When I clicked it, I can not go directly to the page. I have to right-clicked on it to go to the desired page.
Here's an example of my controller
public function cquotation(){
$data = $this->salesModel->showCustomer();
$this->load->view('v_navbar');
$this->load->view('v_leftside');
$this->load->view('v_cquotation',array('data'=>$data));
}
Do you guys have any idea what's wrong with it?
I'm totally confused
Why are you using data-toggle="collapse" class="collapsed" on every hyperlink?. your code has data-toggle="collapse" class="collapsed" in every hyperlink.Bootstrap will prevent the default click event of a href .So remove every data-toggle="collapse" class="collapsed" part of a href in your code and it will work.
<li>
<i class="fa fa-flag-checkered" aria-hidden="true"></i> <span>Lead</span> <i class="icon-submenu lnr lnr-chevron-left"></i>
<div id="lead" class="collapse ">
<ul class="nav">
<li><i class="fa fa-quote-right" aria-hidden="true"></i><span> Quotation </span><i class="icon-submenu lnr lnr-chevron-left"></i>
<div id="quotation" class="collapse ">
<ul class="nav">
<li></i> Create Quotation</li>
<li></i> Quotation Summary</li>
<li></i> Send Quotation</li>
</ul>
</div>
</li>
</ul>
</div>
</li>
To do the login / logout of my website, I use a simple button that leads to a modal form who leads to a log action for the login.
For the logout, the best way I found is to use a dummy form who just contains the logout button that leads to the log action.
Everything works but the dummy forms kills my navbar design.
PHP Code :
<!-- Login -->
<?php
if(!isset($_SESSION['user'])) {
echo '
<button class="btn btn-outline-info my-2 my-sm-0" type="button" data-toggle="modal" data-target="#ModalExample" style="margin-left: 10px">Login</button>
';
}
else {
echo '
<form action="actions/log.php" method="post">
<input type="submit" value="Log out" class="btn btn-outline-danger my-2 my-sm-0" style="margin-left: 10px">
</form>
';
}
?>
Navbar :
<nav class="navbar fixed-top navbar-toggleable-md navbar-light bg-faded" data-spy="affix" data-offset-top="90">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">Beauty Website</a>
<div class="collapse navbar-collapse" id="navbarTogglerDemo02">
<ul class="navbar-nav mr-auto mt-2 mt-md-0">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#about">About us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#othersec">Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#versatility">Offers</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#lightbox">Gallery</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#opportunities">Shop</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#contact">Appointment</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#contact">Contact us</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
Do you know how i could make it better ?
Thanks for you help, I just forgot I had a class in my navbar form.
Here is the working PHP:
<!-- Login -->
<?php
if(!isset($_SESSION['user'])) {
echo '
<button class="btn btn-outline-info my-2 my-sm-0" type="button" data-toggle="modal" data-target="#ModalExample" style="margin-left: 10px">Login</button>
';
}
else {
echo '
<form class="form-inline my-2 my-lg-0" action="actions/log.php" method="post">
<input type="submit" value="Log out" class="btn btn-outline-danger my-2 my-sm-0" style="margin-left: 10px">
</form>
';
}
?>
Attached is the code snippet of my navigator
<!-- Navigator -->
<div style="position:abolute;top:50px" class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<ul id="yw0" class="nav">
<li class="active">Company</li>
<li><a style="color:black" href="#"><i class="fa fa-lightbulb-o"></i> FAQs</a></li>
<li><a style="color:black" href="#"><i class="fa fa-question-circle"></i> Help Center</a></li>
<li><a style="color:black" href="#"><i class="fa fa-newspaper-o"></i> Press</a></li>
<li><a style="color:black" href="#">Careers</a></li>
<li><a style="color:black" href="#"><i class="fa fa-envelope-o"></i> Contact Us</a></li>
</ul>
</div>
</div>
</div>
<!-- Content -->
I am actually trying to put a logic that whenever I click on a link , it should renderPartial the appropriate file and also highlight the menu below the navigator.. I tried doing the following <a href="<?php $this->renderPartial("company",false); ?>"
But I guess it is not the right way.. dunno how can I achieve it?
This will go into your view file
<!-- Navigator -->
<div style="position:abolute;top:50px" class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<ul id="yw0" class="nav">
<li class="active">Company</li>
<li><a onclick="showData('user')" style="color:black" href="#"><i class="fa fa-lightbulb-o"></i> FAQs</a></li>
<li><a style="color:black" href="#"><i class="fa fa-question-circle"></i> Help Center</a></li>
<li><a style="color:black" href="#"><i class="fa fa-newspaper-o"></i> Press</a></li>
<li><a style="color:black" href="#">Careers</a></li>
<li><a style="color:black" href="#"><i class="fa fa-envelope-o"></i> Contact Us</a></li>
</ul>
</div>
</div>
</div>
<div class="main-content">
<div id="company" class="renderContent">
<?php $this->renderPartial("company",false); ?>
</div>
<div id="user" class="renderContent">
<?php $this->renderPartial("user",false); ?>
</div>
<!--- for every menu item there should be a view rendered here--->
</div>
<!-- Content -->
this will go into your js
function showData(id) {
$('.renderContent').hide();
$('.nav li').removeClass('active');
$(this).addClass('active');
$('#'+id).show();
}
$('.renderContent').hide();