JavaScriptとHTMLを使用してフォームを作成しました。現在、[送信]をクリックすると、フォームのデータがプルスルーされ、ページ下部のテキスト領域にテキスト文字列で表示されます。[送信]ボタンをクリックすると、新しいウィンドウでメールが開きます。2つを組み合わせて、テキスト領域にあったデータを取得して、新しいウィンドウのコンテンツ領域で電子メールにプルスルーする必要があります。これにより、送信されると、電子メールにフォームデータが表示されます。誰か助けてもらえますか?
<html>
<head>
<title>Reservation form</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function open_win()
{
window.open("email response.html");
}
<!--
// This is the check script
function checkit()
{
// In textstring I gather the data that are finally written to the textarea.
var textstring = '';
// First of all, have all the text boxes been filled in?
// This part is treated in the normal page.
// I put all boxes and their values in textstring
for (i=0;i<4;i++) {
var box = document.forms['example'].elements[i];
if (!box.value) {
alert('You haven\'t filled in ' + box.name + '!');
box.focus()
return;
}
textstring += box.name + ': ' + box.value + '\n';
}
// Get value of the 'Car' select box.
user_input = document.example.refer1.options[document.example.refer1.selectedIndex].value;
textstring += '1st Car: ' + user_input + '\n';
user_input = document.example.refer2.options[document.example.refer2.selectedIndex].value;
textstring += '2nd Car: ' + user_input + '\n';
user_input = document.example.refer3.options[document.example.refer3.selectedIndex].value;
textstring += '3rd Car: ' + user_input + '\n';
// Get value of the 'When' radio buttons.
user_input = '';
for (i=0;i<document.forms['example'].when.length;i++) {
if (document.forms['example'].when[i].checked) {
user_input = document.forms['example'].when[i].value;
}
}
textstring += 'When: ' + user_input + '\n';
// Get value of the 'Fee' radio buttons.
user_input = '';
for (i=0;i<document.forms['example'].fee.length;i++) {
if (document.forms['example'].fee[i].checked) {
user_input = document.forms['example'].fee[i].value;
}
}
textstring += 'Fee: £' + (user_input*5) + '\n';
// Write textstring to the textarea.
document.forms['example'].output.value = ("\n*** Thank You for your reservation***"+"\n")+ textstring + ("\n*** End of Form***"+"\n");
}
// -->
</script>
</head>
<body>
<h2>Reservation form</h2>
<div id="header"></div>
<p class="intro"> </p>
<form name="example" action="#" onSubmit="checkit(); return false">
<div align="center">
<table class="form">
<tr>
<td colspan="3"><div align="left">
<p><u><strong> Personal Details</strong></u> </p>
</div></td>
</tr>
<tr>
<td width="125" height="25"> </td>
<td width="315"><div align="left">Name</div></td>
<td width="187"><p>
<input name="Name" />
</p></td>
</tr>
<tr>
<td> </td>
<td><div align="left">Telephone</div></td>
<td><p>
<input name="Telephone" />
</p></td>
</tr>
<tr>
<td> </td>
<td><div align="left">Mobile</div></td>
<td><p>
<input name="Mobile" />
</p></td>
</tr>
<tr>
<td> </td>
<td><div align="left">E-mail</div></td>
<td><p>
<input name="E-mail" />
</p></td>
</tr>
<tr>
<td> </td>
<td>How did you want to learn About us?</td>
<td><p>
</p>
<p>
<input type="checkbox" name="Television" />
Television<br />
<input type="checkbox" name="Radio" />Radio<br />
<input type="checkbox" name="Word of mouth" />Word of mouth<br />
<input type="checkbox" name="Other" />Other</p></td>
</tr>
<tr>
<td colspan="5"><div align="left">
<p><u><strong>Reservation Details</strong></u> </p>
</div></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>Option 1</td>
<td>Option 2</td>
<td>Option 3</td>
</tr>
<tr>
<td> </td>
<td height="56"><p>Please Choose a Car you want to Reserve?</p>
<h5>(You can only Reserve Max 3 Cars per visit)</h5></td>
<td><select name="refer1">
<option value='' selected="selected">--- Select ---</option>
<option value="Ford Fiesta 1.6">Ford Fiesta 1.6</option>
<option value="Ford Fiesta 1.4">Ford Fiesta 1.4</option>
<option value="Ford KA 1.3">Ford KA 1.3</option>
<option value="Nissan Micra 1.1">Nissan Micra 1.1</option>
<option value="Nissan Micra 1.2">Nissan Micra 1.2</option>
<option value="Nissan Micra 1.0">Nissan Micra 1.0</option>
<option value="Peugeot 206 1.1">Peugeot 206 1.1</option>
<option value="Peugeot 206 1.4">Peugeot 206 1.4</option>
<option value="Peugeot 106 1.1">Peugeot 106 1.1</option>
<option value="Renault Clio 1.1">Renault Clio 1.1</option>
<option value="Renault Clio 1.4">Renault Clio 1.4</option>
<option value="Renault Clio 1.2">Renault Clio 1.2</option>
<option value="Toyota Aygo 1.0">Toyota Aygo 1.0</option>
<option value="Toyota IQ 1.0">Toyota IQ 1.0</option>
<option value="Toyota Yaris 1.3">Toyota Yaris 1.3</option>
<option value="Vauxhall Corsa 1.2">Vauxhall Corsa 1.2</option>
<option value="Vauxhall Corsa 1.4">Vauxhall Corsa 1.4</option>
<option value="Vauxhall Corsa 1.0">Vauxhall Corsa 1.0</option>
</select>
</td>
<td width="176"><select name="refer2">
<option value='' selected="selected">--- Select ---</option>
<option value="Ford Fiesta 1.6">Ford Fiesta 1.6</option>
<option value="Ford Fiesta 1.4">Ford Fiesta 1.4</option>
<option value="Ford KA 1.3">Ford KA 1.3</option>
<option value="Nissan Micra 1.1">Nissan Micra 1.1</option>
<option value="Nissan Micra 1.2">Nissan Micra 1.2</option>
<option value="Nissan Micra 1.0">Nissan Micra 1.0</option>
<option value="Peugeot 206 1.1">Peugeot 206 1.1</option>
<option value="Peugeot 206 1.4">Peugeot 206 1.4</option>
<option value="Peugeot 106 1.1">Peugeot 106 1.1</option>
<option value="Renault Clio 1.1">Renault Clio 1.1</option>
<option value="Renault Clio 1.4">Renault Clio 1.4</option>
<option value="Renault Clio 1.2">Renault Clio 1.2</option>
<option value="Toyota Aygo 1.0">Toyota Aygo 1.0</option>
<option value="Toyota IQ 1.0">Toyota IQ 1.0</option>
<option value="Toyota Yaris 1.3">Toyota Yaris 1.3</option>
<option value="Vauxhall Corsa 1.2">Vauxhall Corsa 1.2</option>
<option value="Vauxhall Corsa 1.4">Vauxhall Corsa 1.4</option>
<option value="Vauxhall Corsa 1.0">Vauxhall Corsa 1.0</option>
</select>
</td>
<td width="195"><select name="refer3">
<option value='' selected="selected">--- Select ---</option>
<option value="Ford Fiesta 1.6">Ford Fiesta 1.6</option>
<option value="Ford Fiesta 1.4">Ford Fiesta 1.4</option>
<option value="Ford KA 1.3">Ford KA 1.3</option>
<option value="Nissan Micra 1.1">Nissan Micra 1.1</option>
<option value="Nissan Micra 1.2">Nissan Micra 1.2</option>
<option value="Nissan Micra 1.0">Nissan Micra 1.0</option>
<option value="Peugeot 206 1.1">Peugeot 206 1.1</option>
<option value="Peugeot 206 1.4">Peugeot 206 1.4</option>
<option value="Peugeot 106 1.1">Peugeot 106 1.1</option>
<option value="Renault Clio 1.1">Renault Clio 1.1</option>
<option value="Renault Clio 1.4">Renault Clio 1.4</option>
<option value="Renault Clio 1.2">Renault Clio 1.2</option>
<option value="Toyota Aygo 1.0">Toyota Aygo 1.0</option>
<option value="Toyota IQ 1.0">Toyota IQ 1.0</option>
<option value="Toyota Yaris 1.3">Toyota Yaris 1.3</option>
<option value="Vauxhall Corsa 1.2">Vauxhall Corsa 1.2</option>
<option value="Vauxhall Corsa 1.4">Vauxhall Corsa 1.4</option>
<option value="Vauxhall Corsa 1.0">Vauxhall Corsa 1.0</option>
</select>
</td></tr>
<tr>
<td> </td>
<td><p>Please confirm the number of cars you have reserved:</p><p><h5>(Please note there is a £5 reservation fee per car. This charge needs to be paid on arrival of visit. This will be deducted from the price of the car if purchased.)</h5></p>
</td>
<td><br />
<p>
<input type="radio" name="fee" value="1" />1<br />
<input type="radio" name="fee" value="2" />2<br />
<input type="radio" name="fee" value="3" />3</p></td>
</tr>
<tr>
<td> </td>
<td><p>What day would you like to come and visit the car?</p>
<h5>(You can visit the car any time of your cosen day please contact us for more infomation.)</h5></td>
<td><p>
<input type="radio" name="when" value="MONDAY" />
MONDAY<br />
<input type="radio" name="when" value="TUESDAY" />
TUESDAY
<br />
<input type="radio" name="when" value="WEDNESDAY" />
WEDNESDAY
<br />
<input type="radio" name="when" value="THURSDAY" />
THURSDAY
<br />
<input type="radio" name="when" value="FRIDAY" />
FRIDAY<br />
<input type="radio" name="when" value="SATURDAY-SUNDAY" />
SATURDAY-SUNDAY</p></td></tr>
<tr><td colspan="3"><div align="center">
<input type="submit" value="Submit form" onclick="open_win()"/>
<br />
<input type="reset" />
</div></td></tr>
<tr><td colspan="3"><div align="right">
<textarea cols="45" rows="8" name="output">When you hit 'Submit' the user input will be written to this textarea</textarea>
</div></td></tr>
</table>
</div>
</form>
</body
</html>