View Single Post
  #1 (permalink)  
Old February 7th, 2008, 07:17 PM
roccosiffredi roccosiffredi is offline
Registered User
 
Join Date: Apr 2007
Location: Milano, , Italy.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Radio controls and getElementById

Good morning, I'm trying the getElementById function in a document, but I have a problem with radio controls.
I'd like to get the radio control selected, but it always return me the first radio button and then the value London.
What's the right syntax?

Thanks in advance

My HTML is
<input type="radio" name="city" id="city" value="London">London
<input type="radio" name="city" id="city" value="Madrid">Madrid
<input type="radio" name="city" id="city" value="Milan" checked>Milan


and my Javascript
var city = document.getElementById("city");
alert(city.value);