How to create interactive form with bootstrap - html

My fiddle is here: http://jsfiddle.net/L4hkrwa6/14/
The HTML code is here:
<ul class="nav nav-pills nav-justified">
<li class="nav-item nav-link active"><a data-toggle="tab" href="#Show1">Show1</a></li>
<li class="nav-item nav-link"><a data-toggle="tab" href="#Show2">Show2</a></li>
<li class="nav-item nav-link"><a data-toggle="tab" href="#Show3">Show3</a></li>
</ul>
<div class="tab-content">
<form action="test">
<div id="Show1" class="tab-pane fade in active">
<input type="text" name="OnlyMe"/>
</div>
</form>
<form action="differentTest">
<div id="Show2" class="tab-pane fade">
<input type="text" name="MeAnd23Submit"/>
</div>
<div id="Show3" class="tab-pane fade">
<input type="text" name="MeAnd23Submit2"/>
</div>
<input type="text" name="23"/>
<input type="submit" value="submit"/>
</form>
</div>
When I click on Show1 (and when the page is loaded initially) I want to only see the Input 'OnlyMe'.
When I click on Show2 I want to only see the Inputs 'MeAnd23Submit', '23' and the submit button.
When I click on Show3 I want to only see the Inputs 'MeAnd23Submit2', '23' and the submit button.
I tried several combinations but nothing seems to work, I would appreciate any help...
Thanks in advance!
Update:
This is just a small example with the necessary items to understand the problem. In the "real case" I have many more input fields and I would like to not copy the fields in multiple tab-panes.

Have you tried this: forked fiddle
<ul class="nav nav-pills nav-justified">
<li class="nav-item nav-link active"><a data-toggle="tab" href="#Show1">Show1</a></li>
<li class="nav-item nav-link"><a data-toggle="tab" href="#Show2">Show2</a></li>
<li class="nav-item nav-link"><a data-toggle="tab" href="#Show3">Show3</a></li>
</ul>
<div class="tab-content">
<div id="Show1" class="tab-pane fade in active">
<form action="test">
<input type="text" name="OnlyMe"/>
</form>
</div>
<div id="Show2" class="tab-pane fade">
<form action="differentTest">
<input type="text" name="MeAnd23Submit"/>
<input type="text" name="23"/>
<input type="submit" value="submit"/>
</form>
</div>
<div id="Show3" class="tab-pane fade">
<form action="differentTest">
<input type="text" name="MeAnd23Submit2"/>
<input type="text" name="23"/>
<input type="submit" value="submit"/>
</form>
</div>
</div>

Related

How to expand nav tabs to take equal widths in bootstrap? [duplicate]

This question already has answers here:
Full width tabs using Bootstrap (Support IE)
(9 answers)
Closed 2 years ago.
How can I make those two tabs of login and create account equally spaced and centered as given in the picture? I am only able to get them in the left corner and the tabs take up only as long as the text inside (as given in 2nd image). I want to make the tabs look like this:.
Sample Code :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons#1.3.0/font/bootstrap-icons.css">
</head>
<body>
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a href="#login" id="tab1" class='nav-link active' aria-controls="login" aria-selected='true' role="tab" tabindex=1 data-toggle='tab'>LOGIN</a>
</li>
<li class="nav-item">
<a href="#create-account" id="tab2" class='nav-link' aria-controls="create-account" aria-selected='false' role="tab" tabindex=0 data-toggle='tab'>CREATE ACCOUNT</a>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane active" id="login" role="tabpanel" aria-labelledby="tab1" aria-hidden='false'>
<!-- Addition of Form 1 -->
<form class="d-flex flex-column">
<div class="form-group">
<label for="exampleInputEmail1">Email address <span class='required'>*</span></label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password <span class='required'>*</span></label>
<div class="input-group d-flex flex-row">
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
<div class="input-group-append">
<div class="input-group-text">
<i href='#' class='bi bi-eye-fill ml-2'></i>
</div>
</div>
</div>
</div>
<button type="submit" class="btn btn-hover btn-orange rounded-0">SIGN IN</button><br>
<button type="submit" class="btn btn-hover btn-default2 rounded-0">FORGOT YOUR PASSWORD?</button>
</form>
</div>
</body>
</html>
Per the docs, use the nav-fill class.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons#1.3.0/font/bootstrap-icons.css">
<ul class="nav nav-tabs nav-fill" id="myTab" role="tablist">
<li class="nav-item">
<a href="#login" id="tab1" class='nav-link active' aria-controls="login" aria-selected='true' role="tab" tabindex=1 data-toggle='tab'>LOGIN</a>
</li>
<li class="nav-item">
<a href="#create-account" id="tab2" class='nav-link' aria-controls="create-account" aria-selected='false' role="tab" tabindex=0 data-toggle='tab'>CREATE ACCOUNT</a>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane active" id="login" role="tabpanel" aria-labelledby="tab1" aria-hidden='false'>
<!-- Addition of Form 1 -->
<form class="d-flex flex-column">
<div class="form-group">
<label for="exampleInputEmail1">Email address <span class='required'>*</span></label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password <span class='required'>*</span></label>
<div class="input-group d-flex flex-row">
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
<div class="input-group-append">
<div class="input-group-text">
<i href='#' class='bi bi-eye-fill ml-2'></i>
</div>
</div>
</div>
</div>
<button type="submit" class="btn btn-hover btn-orange rounded-0">SIGN IN</button><br>
<button type="submit" class="btn btn-hover btn-default2 rounded-0">FORGOT YOUR PASSWORD?</button>
</form>
</div>

Creating a Combo Login/Signup Form with Bootstrap

I am trying to create a combo-menu with login and signup functionality using Bootstrap. I have followed Bootstrap and W3Schools samples and everything seems alright, but only the login form is displayed, while the signup form does not display when the Signup tab is clicked.
Here's my code:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"/>
</head>
<body>
<ul class="nav nav-tabs" id="myTab" role="tabList">
<li class="nav-item">
<a class="nav-link active" id="login-tab" data-toggle="tab" href="login.php" role="tab" aria-controls="login" aria-selected="true"><?= Translate::get("Login") ?></a>
</li>
<li class="nav-item">
<a class="nav-link" id="signup-tab" data-toggle="tab" href="login.php" role="tab" aria-controls="signup"><?= Translate::get("Sign Up")?></a>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="login" role="tabpanel" aria-labelledby="login-tab">
<form class="form">
<input class="form-control" type="email" placeholder="<?= Translate::get("Email") ?>"/>
<input class="form-control" type="password" placeholder="<?= Translate::get("Password") ?>" />
<input class="form-control" type="submit" value="<?= Translate::get("Log In")?>"/>
</form>
</div>
<div class="tab-pane fade" id="signup" role="tabpanel" aria-labelledby="signup-tab">
<input type="email" placeholder="<?= Translate::get("Email")?>"/>
<input type="password" placeholder="<?= Translate::get("Password") ?>"/>
<input type="password" placeholder="<?= Translate::get("Enter Password Again") ?>" />
<input type="submit" value="<?= Translate::get("Sign Up")?>"/>
</div>
</div>
<script src="js/jquery.slim.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
</body>
</html>
And the output is like this (The Signup tab does not work):
It is critical that the id of the div used in the tab content be given as href of login or signup hyperlinks. So, for the login button, we will have href="#login" and for the signup button, we'll have href="#signup". Solved ✓

One Common submit button for two html files

I have two html and two different controller files and my requirement is i should display one common submit button for both the forms and it should be disabled until the mandatory fields are entered in both the forms.Here is the attached plunker https://plnkr.co/edit/RAzfWZYuCi0kXPL6PDoT?p=preview
<body ng-controller="myCtrl" class="container">
<ul class="nav nav-tabs">
<li><a data-toggle="tab" href="#menu2">Student Details</a></li>
<li><a data-toggle="tab" href="contactdetails.html">Contact Info</a>
</li>
</ul>
<div class="tab-content">
<div id="menu2" class="tab-pane active">
<div class="form-group">
<label for="name">Student Name:</label>
<input type="name" class="form-control" id="name" ng-
model="students.name" required>
</div>
<div class="form-group">
<label for="age">Age:</label>
<input type="age" class="form-control" id="age" ng-
model="students.age">
</div>
</div>
</div>

Align controls in navbar Bootstrap

I am using Bootstrap 3 in my web application , and below html produces the layout depicated in the image
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" [routerLink]="['']" routerLinkActive="active" >Books & NoteBooks</a>
</div>
<ul class="nav navbar-nav">
<li ><a [routerLink]="['']">Home</a></li>
<li *ngFor="let category of categories">
<a [routerLink]="['./acategories' ,category.name , 'products']" routerLinkActive="active">{{category.name}}</a>
</li>
<li><a [routerLink]="['./acart']" routerLinkActive="active">
<span *ngIf="cartCount > 0" class="badge">{{cartCount}}</span>
<span class="glyphicon glyphicon-shopping-cart"> Bag</span></a></li>
<li><a [routerLink]="['./aorders']" routerLinkActive="active">Order Details</a></li>
<li><a [routerLink]="['./about']" routerLinkActive="active">About</a></li>
<li> > > > </li>
</ul>
<form class="form-inline" (ngSubmit)="onSearch()">
<div class="form-group">
<label class="sr-only" for="exampleInputAmount">Amount (in dollars)</label>
<div class="input-group">
<input type="text" class="form-control" id="exampleInputAmount" placeholder="Item Name">
</div>
</div>
<input type="submit" class="btn btn-primary" value="Search"/>
</form><br>
</div>
Now I would like to have text box and search button vertical aligned middle , any idea what needs to be modified.
You can try with padding-top and padding-bottom. Check out working solution here jsbin
Hope this will help you.
You can try using the .navbar-form class along with the .form-inline class as:
<form class="form-inline navbar-form" role="form" (ngSubmit)="onSearch()">
<div class="form-group">...
After this, maybe you can get rid of the <br> tag after the form closing tag.
Also, if you want to align the Search box and button to the right corner, you can use .navbar-right as well:
<form class="form-inline navbar-form navbar-right" role="form" (ngSubmit)="onSearch()">
<div class="form-group">...

bootstrap form not working as expected

I am trying to make a form with bootstrap 3 and all the labels are centered. It works fine if I just have
<body>
<div style="width:80%; padding:20%">
<form>
form stuff
</form>
</div>
</body>
but if it is inside a tab it aligns all the text in the center of the input/select bar like so
This is what I want it to look like
Sorry about the large amount of code. I can't recreate the issue without it for some reason. The select bar is like the rest with less code.
<!DOCTYPE html>
<html>
<head>
<title>TD Notes</title>
<link href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.css" rel = "stylesheet">
<link rel="stylesheet" href="./styles.css">
<script src='./node_modules/jquery/dist/jquery.min.js'></script>
<script>window.$ = window.jQuery = require('./node_modules/jquery/dist/jquery.min.js');</script>
</head>
<body style="background-color: white; height: 100%; width: 100%; text-align: center">
<script src="jscolor.js"></script>
<div id="navBar" class="container" style="background-color: black; height: 30px; width: 100%" >
<ul class="nav nav-tabs" data-tabs="tabs">
<li class="active"><a data-toggle="tab" href="#Body">Body</a></li>
<li><a data-toggle="tab" href="#AAC">AAC</a></li>
<li><a data-toggle="tab" href="#TPMS">TPMS</a></li>
<li><a data-toggle="tab" href="#BCM">BCM</a></li>
<li><a data-toggle="tab" href="#GBCM">GBCM</a></li>
<li><a data-toggle="tab" href="#MSM">MSM</a></li>
<li><a data-toggle="tab" href="#RX">RX</a></li>
<li><a data-toggle="tab" href="#THC">THC</a></li>
<li><a data-toggle="tab" href="#TX">TX</a></li>
<li><a data-toggle="tab" href="#UID">UID</a></li>
<li><a data-toggle="tab" href="#UPE">UPE</a></li>
<li><a data-toggle="tab" href="#NewProb">New Problem</a></li>
</ul>
</div>
<div id="content" style="width: 80%; padding-left: 20%">
<div class="tab-content" style="width: 100%; height: 100%">
<div class="tab-pane fade in active" id="Body" style="width=100%"></div>
<div class="tab-pane fade" id="AAC"></div>
<div class="tab-pane fade" id="TPMS"></div>
<div class="tab-pane fade" id="BCM"></div>
<div class="tab-pane fade" id="GBCM"></div>
<div class="tab-pane fade" id="MSM"></div>
<div class="tab-pane fade" id="RX"></div>
<div class="tab-pane fade" id="TX"></div>
<div class="tab-pane fade" id="THC"></div>
<div class="tab-pane fade" id="UID"></div>
<div class="tab-pane fade" id="UPE"></div>
<div class="tab-pane fade" id="NewProb">
<form>
<fieldset class="form-group">
<label for="lineType" class="control-label">Line Type</label>
<select class="form-control" id="lineType">
<option>Body</option>
<option>AAC</option>
<option>TPMS</option>
<option>BCM</option>
<option>GBCM</option>
<option>MSM</option>
<option>RX</option>
<option>TX</option>
<option>THC</option>
<option>UID</option>
<option>UPE</option>
</select>
</fieldset>
<fieldset class="form-group">
<label for="testerType" class="control-label">Tester Type</label>
<input class="form-control" id="testerType">
</fieldset>
<fieldset class="form-group">
<label for="productType" class="control-label">Product Type</label>
<input class="form-control" id="productType">
</fieldset>
<fieldset class="form-group">
<label for="partNumber" class="control-label">Part Number</label>
<input class="form-control" id="partNumber">
</fieldset>
<fieldset class="form-group">
<label for="stepNumber" class="control-label">Step Number</label>
<input class="form-control" id="stepNumber">
</fieldset>
<fieldset class="form-group">
<label for="stepName" class="control-label">Step Name</label>
<input class="form-control" id="stepName">
</fieldset>
<fieldset class="form-group">
<label for="Other" class="control-label">Other (Automation, OPUI, Scanners, etc.)</label>
<textarea class="form-control" id="other"></textarea>
</fieldset>
<fieldset class="form-group">
<label for="problem" class="control-label">Problem</label>
<textarea class="form-control" id="problem"></textarea>
</fieldset>
<fieldset class="form-group">
<label for="counterMeasure" class="control-label">Countermeasure</label>
<textarea class="form-control" id="countermeasure"></textarea>
</fieldset>
<fieldset class="form-group">
<label for="engineer" class="control-label">Engineer</label>
<input class="form-control" id="engineer">
</fieldset>
<fieldset class="form-group">
<label for="date" class="control-label">Date</label>
<input class="form-control" id="date">
</fieldset>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
</div>
<script src = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.js"></script>
</body>
</html>