0

How Can I Have a Please wait.. or Loding... label For Loding Data Time below of my Combo box?

I Want, When Switch Between Male And Female, see Loading... under Switch box Please see this Photo

HTML

<body> <form> <select name="users" id="users"> <option value="">Select a person:</option> <option value="1">Male</option> <option value="2">Female</option> </select> <button type="submit" id="for-male" styl>Male</button> <button type="submit" id="for-female">Female</button> </form> <br> <div id="txtHint"><b>Person info will be listed here.</b> </div> </body> 

The javascript will look like this

$(document).ready(function() { $('#users').on('change', function() { $('#for-male, #for-female').hide() var value = $(this).val() if(value == "1") { $('#for-male').show(); } else { $('#for-female').show(); } }); }); 

and the css will be

#for-male, #for-female{ display:none; } 
2
  • Possible duplicate of Show "Loading..." in dropdown box Commented Mar 4, 2017 at 8:45
  • I'm New in Programming. Can You Edit with my code? Commented Mar 4, 2017 at 9:02

1 Answer 1

2
+50

$(document).ready(function() { //save actual text var text = $('#test').html(); $('#users').on('change', function() { $('#for-male, #for-female').hide() var value = $(this).val() if (value == "1") { $('#for-male').show(); } else { $('#for-female').show(); } //change text to loading $('#test').html('Loading...'); //this is demo code for testing, here you will call your ajax function setTimeout(function(){ //change back to orignal text $('#test').html(text); }, 1000); }); });
#for-male, #for-female{ display:none; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <select name="users" id="users"> <option value="">Select a person:</option> <option value="1">Male</option> <option value="2">Female</option> </select> <button type="submit" id="for-male" styl>Male</button> <button type="submit" id="for-female">Female</button> <br> <div id="txtHint"><b id="test">Person info will be listed here.</b> </div>

Sign up to request clarification or add additional context in comments.

3 Comments

I Want, When Switch Between Male And Female, see Loading... in place of Person info will be listed here., I Mean Person info will be listed here. Change to Loading....
I Want, When Switch Between Male And Female, see Loading... under Switch box
Ok wait i am updating my answer

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.