JQuery :- Two Tab Options, Slide Down Form Template
Suppose you want to create a small, dynamic form having to tab options in it.
Example: Password Recovery
I am here taking the example of Password Recovery Form where one have two basic options.
Prerequisite knowledge and Requirements
Suppose you want to create a small, dynamic form having to tab options in it.
Example: Password Recovery
I am here taking the example of Password Recovery Form where one have two basic options.
- Through a link to a registered Email-Id
- Through a Security Question
Prerequisite knowledge and Requirements
- JQuery js file (e.g. jquery.min.js)
- JavaScript
- HTML
- CSS 3
Click here for show/hide code
<html>
<head>
<title></title>
<style type="text/css">
.thisPageRows
{
clear: both;
padding-top: 15px;
}
.thisPageColLeftLeft
{
float: left;
width: 8%;
text-align: right;
padding-top: 2px;
}
.thisPageColLeftRight
{
float: left;
width: 18%;
text-align: right;
padding-right: 6px;
}
.thisPageColRightLeft
{
float: left;
width: 40%;
text-align: center;
padding-top: 5px;
}
.thisPageColRequiredFieldValidators
{
float: left;
width: 2%;
text-align: center;
display: block;
}
.thisPageColRightRight
{
float: left;
width: 20%;
text-align: left;
}
.box-shadow-upper-three-side
{
border-top: solid 1px #CCC;
border-left: solid 1px #CCC;
border-right: solid 1px #CCC;
border-bottom: 0px;
-webkit-border-top-left-radius: 22px;
-webkit-border-top-right-radius: 22px;
-moz-border-radius-topleft: 22px;
-moz-border-radius-topright: 22px;
border-top-left-radius: 22px;
border-top-right-radius: 22px;
-webkit-box-shadow: 0px -2px 4px 4px rgba(98, 100, 100, .60);
-moz-box-shadow: 0px -2px 4px 4px rgba(98, 100, 100, .60);
box-shadow: 0px -2px 4px 4px rgba(98, 100, 100, .60);
}
.box-shadow-lower-three-side
{
border-top: solid 0px #CCC;
border-left: solid 1px #CCC;
border-right: solid 1px #CCC;
border-bottom: solid 1px #CCC;
-webkit-border-radius: 22px;
-webkit-border-top-left-radius: 0;
-moz-border-radius: 22px;
-moz-border-radius-topleft: 0;
border-radius: 22px;
border-top-left-radius: 0;
-webkit-box-shadow: 0px 3px 4px 4px rgba(98, 100, 100, .60);
-moz-box-shadow: 0px 3px 4px 4px rgba(98, 100, 100, .60);
box-shadow: 0px 3px 4px 4px rgba(98, 100, 100, .60);
}
.box-shadow-border-radius
{
border: solid 1px #CCC;
-webkit-border-radius: 22px;
-moz-border-radius: 22px;
border-radius: 22px;
-webkit-box-shadow: 0px 3px 4px 4px rgba(98, 100, 100, .60);
-moz-box-shadow: 0px 3px 4px 4px rgba(98, 100, 100, .60);
box-shadow: 0px 3px 4px 4px rgba(98, 100, 100, .60);
}
.border-radius-upper-three-side
{
border-top: solid 1px #CCC;
border-left: solid 1px #CCC;
border-right: solid 1px #CCC;
border-bottom: 0px;
-webkit-border-top-left-radius: 22px;
-webkit-border-top-right-radius: 22px;
-moz-border-radius-topleft: 22px;
-moz-border-radius-topright: 22px;
border-top-left-radius: 22px;
border-top-right-radius: 22px;
}
.border-radius
{
border: solid 1px #CCC;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#hdnShowResultDiv").val("slideDown");
var hdnShowResultDiv = 'hdnShowResultDiv';
if (document.getElementById(hdnShowResultDiv).value == "hidden") {
document.getElementById("divShowResult").style.display = "none";
}
else if (document.getElementById(hdnShowResultDiv).value == "slideDown") {
$('#divShowResult').slideDown('slow', changeStatus());
}
else if (document.getElementById(hdnShowResultDiv).value == "slideUp") {
document.getElementById("divShowResult").style.display = "block";
$('#divShowResult').slideUp("slow");
}
else if (document.getElementById(hdnShowResultDiv).value == "visible") {
document.getElementById("divShowResult").style.display = "block";
changeStatus();
}
});
function showPasswordRecovery() {
var hdnShowResultPassword = 'hdnShowResultPassword';
if (document.getElementById(hdnShowResultPassword).value == "hidden") {
document.getElementById("divShowResultPassword").style.display = "none";
}
else if (document.getElementById(hdnShowResultPassword).value == "slideDown") {
$('#divShowResultPassword').slideDown('slow');
}
else if (document.getElementById(hdnShowResultPassword).value == "slideUp") {
document.getElementById("divShowResultPassword").style.display = "block";
$('#divShowResultPassword').slideUp("slow");
}
else if (document.getElementById(hdnShowResultPassword).value == "visible") {
document.getElementById("divShowResultPassword").style.display = "block";
}
}
// $(document).ready(function() {
// //changeStatus();
// });
function changeStatusClick(str) {
var hdnStep = 'hdnStep';
var val = $("#" + hdnStep).val();
if (val != str) {
var hdnIsPostBack = 'hdnIsPostBack';
$("#" + hdnIsPostBack).val("0");
$("#" + hdnStep).val(str);
changeStatus();
}
}
function changeStatus() {
var hdnStep = 'hdnStep';
hdnStep = $("#" + hdnStep).val();
var hdnIsPostBack = 'hdnIsPostBack';
hdnIsPostBack = $("#" + hdnIsPostBack).val();
if (hdnStep == 1 && hdnIsPostBack == 0) {
$("#divTabBody2").hide("slow", function () {
$("#divTabHeader1").hide("slow", function () {
$("#divTabHeader1").removeClass();
$("#divTabHeader1").addClass("box-shadow-upper-three-side");
$("#divTabHeader1").show("slow");
$("#divTabHeader2").hide("slow");
$("#divTabHeader2").removeClass();
$("#divTabHeader2").addClass("border-radius-upper-three-side");
$("#divTabHeader2").show("slow", function () {
$("#divTabBody1").slideDown("slow", showPasswordRecovery());
});
});
});
}
else if (hdnStep == 2 && hdnIsPostBack == 0) {
$("#divTabBody1").hide("slow", function () {
$("#divTabHeader2").hide("slow", function () {
$("#divTabHeader2").removeClass();
$("#divTabHeader2").addClass("box-shadow-upper-three-side");
$("#divTabHeader2").show("slow");
$("#divTabHeader1").hide("slow");
$("#divTabHeader1").removeClass();
$("#divTabHeader1").addClass("border-radius-upper-three-side");
$("#divTabHeader1").show("slow", function () {
$("#divTabBody2").slideDown("slow", showPasswordRecovery());
});
});
});
}
else if (hdnStep == 1 && hdnIsPostBack == 1) {
$("#divTabHeader1").removeClass();
$("#divTabHeader1").addClass("box-shadow-upper-three-side");
$("#divTabHeader2").removeClass();
$("#divTabHeader2").addClass("border-radius-upper-three-side");
$("#divTabHeader2").css("display", "block");
$("#divTabHeader1").css("display", "block");
$("#divTabBody2").css("display", "none");
$("#divTabBody1").css("display", "block");
showPasswordRecovery();
}
else if (hdnStep == 2 && hdnIsPostBack == 1) {
$("#divTabHeader2").removeClass();
$("#divTabHeader2").addClass("box-shadow-upper-three-side");
$("#divTabHeader1").removeClass();
$("#divTabHeader1").addClass("border-radius-upper-three-side");
$("#divTabHeader2").css("display", "block");
$("#divTabHeader1").css("display", "block");
$("#divTabBody2").css("display", "block");
$("#divTabBody1").css("display", "none");
showPasswordRecovery();
}
//alert(hdnStep);
}
function inputIsValid()
{
$("#hdnShowResultPassword").val("slideDown");
showPasswordRecovery();
}
</script>
</head>
<body>
<form id="from1" >
<center>
<div id="divContent" style="padding-bottom: 10px;">
<div id="div1" style="padding-top: 17px; padding-left: 12px;">
Heading :: (e.g. Password Recovery )
</div>
<div id="divBody" style="padding-left: 20px;">
<div class="thisPageRows">
<input type="hidden" ID="hdnIsPostBack" />
<input type="hidden" ID="hdnLoginName" Value="0" />
<input type="hidden" ID="hdnEmailId" Value="0" />
<input type="hidden" ID="hdnShowResultDiv" Value="0" />
<input type="hidden" ID="hdnShowResultPassword" Value="0" />
<input type="hidden" ID="hdnStep" Value="1" />
<input type="hidden" ID="hdnSecurityQuestionAnswer" Value="0" />
<input type="hidden" ID="hdnVerificationCode" Value="0" />
<div class="border-radius" id="divPassowrdRecvery" style="width: 400px;
height: auto; padding: 10px;">
<div>
User Name
<input type="text" ID="txtStudyCentreCode" />
<input type="button" ID="btnGetOptions" value="Ok"
/>
<input type="button" ID="btnReset" value="Reset"
/>
</div>
<div class="thisPageRows" id="divShowResult" style="display: none;">
<hr />
<div id="divTabHeader1" class="" style="width: 150px; cursor: pointer; display: none;
height: 50px; float: left; text-align: center;" onclick="changeStatusClick('1')">
<div style="padding-top: 10;">
Email
</div>
</div>
<div id="divTabHeader2" class="" style="width: 150px; cursor: pointer; display: none;
height: 50px; float: left; text-align: center;" onclick="changeStatusClick('2')">
<div style="padding-top: 10;">
Security Question
</div>
</div>
<div id="divTabBody1" class="box-shadow-lower-three-side" style="width: 400px; height: 120px;
display: none; float: left; clear: both;">
<div style="width: 150px; height: 20px; float: left; margin-top: -10px; position: absolute;
background-color: White;">
</div>
<div class="thisPageRows">
Email:
<input type="text" ID="txtEmailId" Visible="false"/>
<input type="button" ID="btnSendEmail" value="Send Email" onclick="inputIsValid()"/>
<input type="button" ID="btnCheckEmail" value="Check" onclick="inputIsValid()" />
</div>
</div>
<div id="divTabBody2" class="box-shadow-lower-three-side" style="width: 400px; height: 120px;
display: none; float: left; clear: both; display: none;">
<div style="width: 150px; height: 20px; float: left; margin-top: -10px; margin-left: 152px;
position: absolute; background-color: White;">
</div>
<div class="thisPageRows">
Security Question: Question?
</div>
<div class="thisPageRows">
<input type="text" ID="txtSecurityQuestionAnswer" />
<input type="button" ID="btnCheckSecurityQuestion" value="Check" onclick="inputIsValid()" />
</div>
</div>
</div>
<div class="thisPageRows">
</div>
<div class="thisPageRows box-shadow-border-radius" id="divShowResultPassword" style="display: none;
height: 130px; width: 400px;">
<div>
New Password:
<input type="password" ID="txtNewPassword" />
</div>
<div class="thisPageRows">
Confirm Password:
<input type="password" ID="txtConfirmPassword" />
</div>
<div class="thisPageRows">
<input type="button" ID="btnSubmit" value="Submit"
/>
</div>
</div>
</div>
</div>
</div>
</div>
</center>
</form>
</body>
</html>
<head>
<title></title>
<style type="text/css">
.thisPageRows
{
clear: both;
padding-top: 15px;
}
.thisPageColLeftLeft
{
float: left;
width: 8%;
text-align: right;
padding-top: 2px;
}
.thisPageColLeftRight
{
float: left;
width: 18%;
text-align: right;
padding-right: 6px;
}
.thisPageColRightLeft
{
float: left;
width: 40%;
text-align: center;
padding-top: 5px;
}
.thisPageColRequiredFieldValidators
{
float: left;
width: 2%;
text-align: center;
display: block;
}
.thisPageColRightRight
{
float: left;
width: 20%;
text-align: left;
}
.box-shadow-upper-three-side
{
border-top: solid 1px #CCC;
border-left: solid 1px #CCC;
border-right: solid 1px #CCC;
border-bottom: 0px;
-webkit-border-top-left-radius: 22px;
-webkit-border-top-right-radius: 22px;
-moz-border-radius-topleft: 22px;
-moz-border-radius-topright: 22px;
border-top-left-radius: 22px;
border-top-right-radius: 22px;
-webkit-box-shadow: 0px -2px 4px 4px rgba(98, 100, 100, .60);
-moz-box-shadow: 0px -2px 4px 4px rgba(98, 100, 100, .60);
box-shadow: 0px -2px 4px 4px rgba(98, 100, 100, .60);
}
.box-shadow-lower-three-side
{
border-top: solid 0px #CCC;
border-left: solid 1px #CCC;
border-right: solid 1px #CCC;
border-bottom: solid 1px #CCC;
-webkit-border-radius: 22px;
-webkit-border-top-left-radius: 0;
-moz-border-radius: 22px;
-moz-border-radius-topleft: 0;
border-radius: 22px;
border-top-left-radius: 0;
-webkit-box-shadow: 0px 3px 4px 4px rgba(98, 100, 100, .60);
-moz-box-shadow: 0px 3px 4px 4px rgba(98, 100, 100, .60);
box-shadow: 0px 3px 4px 4px rgba(98, 100, 100, .60);
}
.box-shadow-border-radius
{
border: solid 1px #CCC;
-webkit-border-radius: 22px;
-moz-border-radius: 22px;
border-radius: 22px;
-webkit-box-shadow: 0px 3px 4px 4px rgba(98, 100, 100, .60);
-moz-box-shadow: 0px 3px 4px 4px rgba(98, 100, 100, .60);
box-shadow: 0px 3px 4px 4px rgba(98, 100, 100, .60);
}
.border-radius-upper-three-side
{
border-top: solid 1px #CCC;
border-left: solid 1px #CCC;
border-right: solid 1px #CCC;
border-bottom: 0px;
-webkit-border-top-left-radius: 22px;
-webkit-border-top-right-radius: 22px;
-moz-border-radius-topleft: 22px;
-moz-border-radius-topright: 22px;
border-top-left-radius: 22px;
border-top-right-radius: 22px;
}
.border-radius
{
border: solid 1px #CCC;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#hdnShowResultDiv").val("slideDown");
var hdnShowResultDiv = 'hdnShowResultDiv';
if (document.getElementById(hdnShowResultDiv).value == "hidden") {
document.getElementById("divShowResult").style.display = "none";
}
else if (document.getElementById(hdnShowResultDiv).value == "slideDown") {
$('#divShowResult').slideDown('slow', changeStatus());
}
else if (document.getElementById(hdnShowResultDiv).value == "slideUp") {
document.getElementById("divShowResult").style.display = "block";
$('#divShowResult').slideUp("slow");
}
else if (document.getElementById(hdnShowResultDiv).value == "visible") {
document.getElementById("divShowResult").style.display = "block";
changeStatus();
}
});
function showPasswordRecovery() {
var hdnShowResultPassword = 'hdnShowResultPassword';
if (document.getElementById(hdnShowResultPassword).value == "hidden") {
document.getElementById("divShowResultPassword").style.display = "none";
}
else if (document.getElementById(hdnShowResultPassword).value == "slideDown") {
$('#divShowResultPassword').slideDown('slow');
}
else if (document.getElementById(hdnShowResultPassword).value == "slideUp") {
document.getElementById("divShowResultPassword").style.display = "block";
$('#divShowResultPassword').slideUp("slow");
}
else if (document.getElementById(hdnShowResultPassword).value == "visible") {
document.getElementById("divShowResultPassword").style.display = "block";
}
}
// $(document).ready(function() {
// //changeStatus();
// });
function changeStatusClick(str) {
var hdnStep = 'hdnStep';
var val = $("#" + hdnStep).val();
if (val != str) {
var hdnIsPostBack = 'hdnIsPostBack';
$("#" + hdnIsPostBack).val("0");
$("#" + hdnStep).val(str);
changeStatus();
}
}
function changeStatus() {
var hdnStep = 'hdnStep';
hdnStep = $("#" + hdnStep).val();
var hdnIsPostBack = 'hdnIsPostBack';
hdnIsPostBack = $("#" + hdnIsPostBack).val();
if (hdnStep == 1 && hdnIsPostBack == 0) {
$("#divTabBody2").hide("slow", function () {
$("#divTabHeader1").hide("slow", function () {
$("#divTabHeader1").removeClass();
$("#divTabHeader1").addClass("box-shadow-upper-three-side");
$("#divTabHeader1").show("slow");
$("#divTabHeader2").hide("slow");
$("#divTabHeader2").removeClass();
$("#divTabHeader2").addClass("border-radius-upper-three-side");
$("#divTabHeader2").show("slow", function () {
$("#divTabBody1").slideDown("slow", showPasswordRecovery());
});
});
});
}
else if (hdnStep == 2 && hdnIsPostBack == 0) {
$("#divTabBody1").hide("slow", function () {
$("#divTabHeader2").hide("slow", function () {
$("#divTabHeader2").removeClass();
$("#divTabHeader2").addClass("box-shadow-upper-three-side");
$("#divTabHeader2").show("slow");
$("#divTabHeader1").hide("slow");
$("#divTabHeader1").removeClass();
$("#divTabHeader1").addClass("border-radius-upper-three-side");
$("#divTabHeader1").show("slow", function () {
$("#divTabBody2").slideDown("slow", showPasswordRecovery());
});
});
});
}
else if (hdnStep == 1 && hdnIsPostBack == 1) {
$("#divTabHeader1").removeClass();
$("#divTabHeader1").addClass("box-shadow-upper-three-side");
$("#divTabHeader2").removeClass();
$("#divTabHeader2").addClass("border-radius-upper-three-side");
$("#divTabHeader2").css("display", "block");
$("#divTabHeader1").css("display", "block");
$("#divTabBody2").css("display", "none");
$("#divTabBody1").css("display", "block");
showPasswordRecovery();
}
else if (hdnStep == 2 && hdnIsPostBack == 1) {
$("#divTabHeader2").removeClass();
$("#divTabHeader2").addClass("box-shadow-upper-three-side");
$("#divTabHeader1").removeClass();
$("#divTabHeader1").addClass("border-radius-upper-three-side");
$("#divTabHeader2").css("display", "block");
$("#divTabHeader1").css("display", "block");
$("#divTabBody2").css("display", "block");
$("#divTabBody1").css("display", "none");
showPasswordRecovery();
}
//alert(hdnStep);
}
function inputIsValid()
{
$("#hdnShowResultPassword").val("slideDown");
showPasswordRecovery();
}
</script>
</head>
<body>
<form id="from1" >
<center>
<div id="divContent" style="padding-bottom: 10px;">
<div id="div1" style="padding-top: 17px; padding-left: 12px;">
Heading :: (e.g. Password Recovery )
</div>
<div id="divBody" style="padding-left: 20px;">
<div class="thisPageRows">
<input type="hidden" ID="hdnIsPostBack" />
<input type="hidden" ID="hdnLoginName" Value="0" />
<input type="hidden" ID="hdnEmailId" Value="0" />
<input type="hidden" ID="hdnShowResultDiv" Value="0" />
<input type="hidden" ID="hdnShowResultPassword" Value="0" />
<input type="hidden" ID="hdnStep" Value="1" />
<input type="hidden" ID="hdnSecurityQuestionAnswer" Value="0" />
<input type="hidden" ID="hdnVerificationCode" Value="0" />
<div class="border-radius" id="divPassowrdRecvery" style="width: 400px;
height: auto; padding: 10px;">
<div>
User Name
<input type="text" ID="txtStudyCentreCode" />
<input type="button" ID="btnGetOptions" value="Ok"
/>
<input type="button" ID="btnReset" value="Reset"
/>
</div>
<div class="thisPageRows" id="divShowResult" style="display: none;">
<hr />
<div id="divTabHeader1" class="" style="width: 150px; cursor: pointer; display: none;
height: 50px; float: left; text-align: center;" onclick="changeStatusClick('1')">
<div style="padding-top: 10;">
</div>
</div>
<div id="divTabHeader2" class="" style="width: 150px; cursor: pointer; display: none;
height: 50px; float: left; text-align: center;" onclick="changeStatusClick('2')">
<div style="padding-top: 10;">
Security Question
</div>
</div>
<div id="divTabBody1" class="box-shadow-lower-three-side" style="width: 400px; height: 120px;
display: none; float: left; clear: both;">
<div style="width: 150px; height: 20px; float: left; margin-top: -10px; position: absolute;
background-color: White;">
</div>
<div class="thisPageRows">
Email:
<input type="text" ID="txtEmailId" Visible="false"/>
<input type="button" ID="btnSendEmail" value="Send Email" onclick="inputIsValid()"/>
<input type="button" ID="btnCheckEmail" value="Check" onclick="inputIsValid()" />
</div>
</div>
<div id="divTabBody2" class="box-shadow-lower-three-side" style="width: 400px; height: 120px;
display: none; float: left; clear: both; display: none;">
<div style="width: 150px; height: 20px; float: left; margin-top: -10px; margin-left: 152px;
position: absolute; background-color: White;">
</div>
<div class="thisPageRows">
Security Question: Question?
</div>
<div class="thisPageRows">
<input type="text" ID="txtSecurityQuestionAnswer" />
<input type="button" ID="btnCheckSecurityQuestion" value="Check" onclick="inputIsValid()" />
</div>
</div>
</div>
<div class="thisPageRows">
</div>
<div class="thisPageRows box-shadow-border-radius" id="divShowResultPassword" style="display: none;
height: 130px; width: 400px;">
<div>
New Password:
<input type="password" ID="txtNewPassword" />
</div>
<div class="thisPageRows">
Confirm Password:
<input type="password" ID="txtConfirmPassword" />
</div>
<div class="thisPageRows">
<input type="button" ID="btnSubmit" value="Submit"
/>
</div>
</div>
</div>
</div>
</div>
</div>
</center>
</form>
</body>
</html>
No comments:
Post a Comment