Select Previous Value of Dropdown on Custom Click Button
How do I make an select previous value of dropdown on custom click button?
Select Previous Value of Dropdown on Custom Click Button. What is a select previous value of dropdown on custom click button? How do you make a select previous value of dropdown on custom click button? This script and codes were developed by Ahsan K. Rathore on 04 July 2022, Monday.
Select Previous Value of Dropdown on Custom Click Button - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Select Previous Value of Dropdown on Custom Click Button</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <h3>Select Previous Value of Dropdown on Custom Click Button</h3>
<select id="DateFilterDropdown"> <option value="choose">Choose Date</option> <option value="today">Today</option> <option value="yesterday">Yesterday</option> <option value="thisWeek">This Week</option> <option value="thisMonth">This Month</option> <option value="custom">Custom</option>
</select>
<div id="today" class="content"> <a href="javascript:void(0)" class="content-close" onclick="RestorePreviousOption(this);">Close</a> <h1 class="content-heading">Today Data</h1>
</div>
<div id="yesterday" class="content"> <a href="javascript:void(0)" class="content-close" onclick="RestorePreviousOption(this);">Close</a> <h1 class="content-heading">Yesterday Data</h1>
</div>
<div id="thisWeek" class="content"> <a href="javascript:void(0)" class="content-close" onclick="RestorePreviousOption(this);">Close</a> <h1 class="content-heading">This Week Data</h1>
</div>
<div id="thisMonth" class="content"> <a href="javascript:void(0)" class="content-close" onclick="RestorePreviousOption(this);">Close</a> <h1 class="content-heading">This Month Data</h1>
</div>
<div id="custom" class="content"> <a href="javascript:void(0)" class="content-close" onclick="RestorePreviousOption(this);">Close</a> <h1 class="content-heading">Custom Data</h1> <div class="custom-date-picker-popup"> <div class="date-span"> <span class="label">From Date</span> <span class="field"> <input type="text"> <span class="error">*From date cannot be empty</span> </span> </div> <div class="date-span"> <span class="label">End Date</span> <span class="field"> <input type="text"> <span class="error">*End date cannot be empty</span> </span> </div> <div class="date-span"> <span class="label"></span> <span class="field"> <input type="button" value="Done"> <input type="button" value="Cancel" onclick="RestorePreviousOption(this);"> </span> </div> </div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Select Previous Value of Dropdown on Custom Click Button - Script Codes CSS Codes
body{ font-family: tahoma; font-size: 16px;
}
#DateFilterDropdown { padding: 10px; border-radius: 2px; font-size: 16px; /* Comment */
}
.content { border: 1px solid #ccc; padding: 15px; margin-top: 15px; display: none;
}
.content-heading { display: block; margin-right: 100px; font-size: 16px; font-weight: normal; padding:0px; margin: 0px;
}
a:hover{text-decoration: underline;}
.content-close { width: 100px; float: right; display: block; text-align: right; text-decoration:none; color: royalblue;
}
.custom-date-picker-popup { background-color: #e4e4e4; padding: 25px; margin-top: 50px; width: 300px; margin: 0 auto;
}
.date-span { display: block; font-size: 14px; font-family: tahoma; overflow: hidden; margin-bottom: 10px;
}
.date-span span.label { width: 100px; text-align : right; float: left; line-height: 27px; display: block;
}
.date-span span.field { display: block; margin-left: 110px;
}
.date-span span.field input[type=text] { width : 135px; padding: 5px 10px; display: block;
}
.date-span span.field span.error { display: none; color: red; font-size: 12px; margin-left: 0px; padding: 5px 0; width: 100%;
}
Select Previous Value of Dropdown on Custom Click Button - Script Codes JS Codes
var oldDropdownValue = 'choose';
$('#DateFilterDropdown').on('mousedown', function() { var newddlval = $(this).val(); oldDropdownValue = newddlval;
});
$('#DateFilterDropdown').on('change', function() { var ddlvalue = $(this).val(); $('.content').hide(); $("#" + ddlvalue).fadeIn(300);
});
function RestorePreviousOption(el) { var elmVal = $(el).parent().attr('id'); if(oldDropdownValue == elmVal) { $('#DateFilterDropdown').val('choose'); $('.content').hide(); } else { $('#DateFilterDropdown').val(oldDropdownValue); $('.content').hide(); $("#" + oldDropdownValue).fadeIn(300); }
}
Developer | Ahsan K. Rathore |
Username | ahsanrathore |
Uploaded | July 04, 2022 |
Rating | 3 |
Size | 2,690 Kb |
Views | 36,432 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
One page responsive website By Ahsan Khurshid | 6,327 Kb |
JQCap - jQuery Captcha Widget | 3,935 Kb |
Full Calendar - Isotope | 2,895 Kb |
Parallax Content | 4,511 Kb |
Responsive Mega Menu - CSS3 | 4,373 Kb |
Responsive Layout with Flexbox | 1,831 Kb |
Get a Quote Widget for Taxi Services in UK | 3,746 Kb |
A Pen by Ahsan K. Rathore | 2,027 Kb |
Bootstrap Modal Example | 2,183 Kb |
SVG Path Animation using CSS3 | 5,961 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Static Image to Video Block | Grayghostvisuals | 4,864 Kb |
Next Word Predictor | Rfalor | 2,776 Kb |
Voting App - register | MatheusLima92 | 1,948 Kb |
Fluid Layout with Float | Jxqr97 | 1,785 Kb |
Swiftype Lower Third | Zumwalt | 4,796 Kb |
Ionic Infinite outside ion-content with ion-pane | Felquis | 3,117 Kb |
Ball bouncing loading animation | Adam2326 | 3,144 Kb |
Fellowship of the Ring | Aussieyang | 2,639 Kb |
Comment Jquery | SquishyAndroid | 2,421 Kb |
Flat iOS 7 Safari Icon | Rss | 3,332 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!