Add Values In Dropdown box Using Javascript | Add States in Dropdown When Countries Is Selected

Опубликовано: 16 Октябрь 2024
на канале: Unpossible POG
61,041
525

Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)

Code Link :-
https://unpossiblepog.blogspot.com/20...

Subscribe my Channel:-
(I improved a code little bit so that 2nd dropdown's attributes will remain the same.)
http://www.youtube.com/user/SanketRoo...

Facebook Page:-
  / unpossiblens  

Twitter Account:-
  / unpossiblepog  

Blog Account :-
http://unpossiblepog.blogspot.in/

Hey guys, this is unpossible pog.
Today’s tutorial will be how to add values in dropdown when we select other dropdown.in this case we are adding states or cities in dropdown when you select contries.
First create a normal dorpdown, give it an ID as “input”.
I shall add nations in it.
Let’s check it.
Now add script tag, and create a function with any random name.
In select tag, onchange event, call the function name.
Now, the function is called correctly.
But we don’t need alert, so I shall remove it.
Lets create a variable “a” to get nation name from dropdown.
Then create division and give it an ID as “output”.
Lets print the nation’s name.
So far so good.
Now we need if else statements.
Give equals to symbol “three times”.
Add states in array.
We need a string and for loop.
We are appending the string.
Change “a” to “string”.
Let’s check if all states are coming or not.
Before and after array, add option tag in double quote.
Add name if you want to send it through form.
Add select tag inside div just to make an illusion.
So thats it guys, if you want code, then the link is in the description.
don’t forget to Like,share and subscribe. Thank you for watching, bye.