JSFiddle - React, Tailwind, and code Playground
by lemon kazi
HTML
<html>
<head>
<script type="text/javascript">
function CheckColors(val){
var element=document.getElementById('color');
if(val=='others')
element.style.display='block';
else
element.style.display='none';
}
</script>
</head>
<body>
<select name="strings" id="strings" onchange='CheckColors(this.value);'>
<option>Nationality</option>
</select>
<input type="text" name="color" id="color" style='display:none;'/>
</body>
</html>
JavaScript
var select, i, option;
var guest_country = 'japan';//this will come from bed24
//var guest_country = 'Japanese'; //from bed24
//var guest_country = 'Korean'; //from bed24
//var guest_country = 'Singapore'; //from bed24
var japanese = "Japanese";
var Chinese = "Chinese";
var Korean = "Korean";
if(japanese.toLowerCase().indexOf(guest_country.toLowerCase()) !== -1){
var guest_country = 'Japanese';//this will come from bed24
} //true
else if(Korean.toLowerCase().indexOf(guest_country.toLowerCase()) !== -1){
var guest_country = 'Korean';//this will come from bed24
} //true
else if(Chinese.toLowerCase().indexOf(guest_country.toLowerCase()) !== -1){
var guest_country = 'Chinese';//this will come from bed24
} //true
else {
var guest_country = guest_country;//this will come from bed24
} //true
select = document.getElementById( 'strings' );
if (guest_country == 'Japanese') {
var jpvalues = ["Japanese","others"];
var arrayLength = jpvalues.length;
for (var i = 0; i < arrayLength; i++) {
//console.log(myStringArray[i]);
option = document.createElement( 'option' );
option.value = option.text = jpvalues[i];
select.add( option );
}
}
else if (guest_country == 'Korean') {
var jpvalues = ["Korean","others"];
var arrayLength = jpvalues.length;
for (var i = 0; i < arrayLength; i++) {
//console.log(myStringArray[i]);
option = document.createElement( 'option' );
option.value = option.text = jpvalues[i];
select.add( option );
}
}
else if (guest_country == 'Chinese') {
var jpvalues = ["Chinese", "Taiwan", "Hong Kong", "Singapore", "Macao", "others"];
var arrayLength = jpvalues.length;
for (var i = 0; i < arrayLength; i++) {
//console.log(myStringArray[i]);
option = document.createElement( 'option' );
option.value = option.text = jpvalues[i];
select.add( option );
}
}
else{
var jpvalues = ["Singapore", "India", "USA", "UK", "etc","others"];
var arrayLength =...