How do you join these two pieces of code? HTML <!DOCTYPE html> < html> < head> <
ID: 3822657 • Letter: H
Question
How do you join these two pieces of code?
HTML
<!DOCTYPE html>
< html>
< head>
< meta charset="utf-8">
< meta name="viewport" content="width=device-width">
< script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
< title>JS Bin</title>
< /head>
< body>
< form>
< input type="radio" name="sendto" id="tofaculty" value="Faculty" checked>Faculty<br>
< input type="radio" name="sendto" id="tostudent" value="Student"> Student<br>
< /br>
< input type="button" class="SendMail" value="Submit">
< /form>
< /body>
< /html>
JavaScript:
function pushmail()
{
if(document.getElementById("tofaculty").checked)
{
var email = 'faculty@eee.com';
var subject = 'Test';
var emailBody = 'Hi Sample,';
var attach = 'path';
document.location = "mailto:"+email+"?subject="+subject+"&body="+emailBody+
"?attach="+attach;
}
else if(document.getElementById("tostudent").checked)
{
var email = 'student@eee.com';
var subject = 'Test';
var emailBody = 'Hi Sample,';
var attach = 'path';
document.location = "mailto:"+email+"?subject="+subject+"&body="+emailBody+
"?attach="+attach;
}
else
{
confirm("select any to person.");
}
}
Explanation / Answer
i have linked these two codes and now after clicking on sumit button you will redirect to your mail box. like i use macbook so it is redirected to my mail application. it will open a page where yout default mail has been set.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<title>JS Bin</title>
</head>
<body>
<form method="get" action="">
<input type="text" name="name" placeholder="name"/>
<input type="radio" name="sendto" id="tofaculty" value="Faculty" checked>Faculty<br>
<input type="radio" name="sendto" id="tostudent" value="Student"> Student<br>
</br>
<input type="button" class="SendMail" value="Submit">
</form>
</body>
</html>
<script type="text/javascript">
function pushmail()
{
if(document.getElementById("tofaculty").checked)
{
var email = 'faculty@eee.com';
var subject = 'Test';
var emailBody = 'Hi Sample,';
var attach = 'sam';
document.location = "mailto:"+email+"?subject="+subject+"&body="+emailBody+
"?attach="+attach;
alert("demo Message");
}
else if(document.getElementById("tostudent").checked)
{
var email = 'student@eee.com';
var subject = 'Test';
var emailBody = 'Hi Sample,';
var attach = 'Sid';
document.location = "mailto:"+email+"?subject="+subject+"&body="+emailBody+
"?attach="+attach;
}
else
{
confirm("select any to person.");
}
}
</script>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.