jssuche
03-25-2010, 06:53 AM
I have three radio button groups with different values. My script only works for one group. Please help!
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
function emailTo(){
var emails = document.getElementsByName("email1");
var emailAdress = null;
for(var i = 0; i < emails.length; i++){
if(emails[i].checked){
emailAdress = emails[i].value;
}
}
if(emailAdress == null){
alert("select the email address");
return;
}
var mailto_link = 'mailto:'+emailAdress;
var win = window.open(mailto_link,'emailWindow');
if (win && win.open &&!win.closed) win.close();
}
</script>
</head>
<body>
<p>
<input type = "radio" name = "email1" value = "email1.com"/>
recipient 1a
<input type = "radio" name = "email1" value = "email1.com">
recipient 1b
</p>
<p>
<input type = "radio" name = "email2" value = "email2.com"/>
recipient 2a
<input type = "radio" name = "email2" value = "email2.com">
recipient 2b</p>
<p>
<input type = "radio" name = "email3" value = "email3.com"/>
recipient 3a
<input type = "radio" name = "email3" value = "email3.com">
recipient 3b</p>
<p> </p>
<p>
<input type = "button" onClick = "emailTo()" value = "Email"/>
</p>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
function emailTo(){
var emails = document.getElementsByName("email1");
var emailAdress = null;
for(var i = 0; i < emails.length; i++){
if(emails[i].checked){
emailAdress = emails[i].value;
}
}
if(emailAdress == null){
alert("select the email address");
return;
}
var mailto_link = 'mailto:'+emailAdress;
var win = window.open(mailto_link,'emailWindow');
if (win && win.open &&!win.closed) win.close();
}
</script>
</head>
<body>
<p>
<input type = "radio" name = "email1" value = "email1.com"/>
recipient 1a
<input type = "radio" name = "email1" value = "email1.com">
recipient 1b
</p>
<p>
<input type = "radio" name = "email2" value = "email2.com"/>
recipient 2a
<input type = "radio" name = "email2" value = "email2.com">
recipient 2b</p>
<p>
<input type = "radio" name = "email3" value = "email3.com"/>
recipient 3a
<input type = "radio" name = "email3" value = "email3.com">
recipient 3b</p>
<p> </p>
<p>
<input type = "button" onClick = "emailTo()" value = "Email"/>
</p>
</body>
</html>