Select Previous Value of Dropdown on Custom Click Button

Size
2,690 Kb
Views
36,432

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 Previews

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); }
}
Select Previous Value of Dropdown on Custom Click Button - Script Codes
Select Previous Value of Dropdown on Custom Click Button - Script Codes
Home Page Home
Developer Ahsan K. Rathore
Username ahsanrathore
Uploaded July 04, 2022
Rating 3
Size 2,690 Kb
Views 36,432
Do you need developer help for Select Previous Value of Dropdown on Custom Click Button?

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!

Ahsan K. Rathore (ahsanrathore) Script Codes
Create amazing blog posts with AI!

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!