How to keep elements hide() show() states on page load?
Hello,
I have a CRUD in PHP where the user selects 2 options in a dropdown menu, based on the select 1 field or another shows up where the user input a number.
My problem is this:
If the user choose choice 2 which shows input 2 and send the information to my databasem on the next page load the php will show the choice 2 but the input will not show up until I click again on the dropdown menu...
How to get jquery to load automatically based on the dropdown selection please?
Here is my code:
- $j(document).ready(function(){
- //Hide these 2 elements when the page is loaded
- $j("#quantity").hide();
- $j("label[for='quantity']").hide();
- //When user changes the dropdown menu state show this or that...
- $j('#prize_quantity').on('change', function() {
- if ( this.value == 'Limited')
- {//The below code is not changing until I select again "Limited" via the dropdown menu..
- $j("#quantity").show();
- $j("label[for='quantity']").show();
- $j('#quantity').attr('required', true)
- }
- else
- {
- $j("#quantity").hide();
- $j("label[for='quantity']").hide();
- }
- }).change();
- });
Thanks!
Ben