I made a web page where if a person clicked on a
<input type = "radio" name = "city" value = "lubum" onclick = "citySelect(city.value)">
This code...
function citySelect(cty) {
if(cty == "lubum"){
document.getElementById("desc").innerHTML = "This is for Lubumbashi city/town! ^_^";
}else {
document.getElementById("desc").innerHTML = "City Description";
}
}
...would change the text to "This is for Lubumbashi city/town! ^_^" here is the interesting part. I did not declare a city variable and yet the code runs. I changed the input tag's name attribute and the "citySelect(city.value)" to "d". Just to check if it would work.
It worked.
I did not need any of this
var k = document.getElementId("city"); //or the var city = k.value;
So is this something new in JS. I don't see people using it.