Google翻译Javascript生成的内容
|
使用Google Translate(使用我在下面采用的方法)时,是否有任何方法可以翻译从用户表单输入生成的内容?
现在,页面将进行翻译,但是当用户填写并在翻译后的页面上提交表格后,答案当然会以英语返回。这是有道理的,因为翻译是在表单提交之前进行的(并且在Google的服务器上进行)。
有什么相对简单的方法可以解决吗?我仍然对JavaScript感到陌生,因此非常感谢您提供的任何详细信息。一想到这,我的小脑袋就会爆炸。
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />
<title>Untitled Document</title>
<script type=\"text/javascript\">
<!-- Begin CE MP Savings Calc script
function doMath3() {
var one = parseInt(document.theForm3.elements[0].value);
var two = parseInt(document.theForm3.elements[1].value);
var three = one * two;
var z4yearlyCash = three * 4.25 * 12;
var z3yearlyCash = three * 3.75 * 12;
var z2yearlyCash = three * 3 * 12;
var z1yearlyCash = three * 2.5 * 12;
var baseyearlyCash = three * 1.5 * 12;
var selection = document.getElementsByName(\"zone\")[0].value;
var answerCemp = document.getElementById(\"answerCemp\");
if (document.theForm3.elements[0].value == \"\"){
alert(\"Please enter the number of days a month you commute on Commuter Express.\")
}
if (document.theForm3.elements[1].value == \"\"){
alert(\"Please enter the number of times you board a Commuter Express daily.\")
}
if(one > 31){
alert(\"Come now, no month has \" + one + \" days! Please try again.\");
}
else if(selection == \"z4\"){
var prodZ4 = z4yearlyCash - 1680;
if(prodZ4 > 0){
answerCemp.innerHTML=\"<div class=\'answerbox\'><h3>Your Yearly Savings<\\/h3><p>If you pay cash, your yearly expense is $\" + z4yearlyCash + \".<br>Commuter Express Zone 4 Monthly Passes cost $1680 per year.<br><strong>That's a yearly savings of $\" + prodZ4 + \"!<\\/strong><br><strong><a href=\'http://store.ladottransit.com/Merchant2/merchant.mvc?Screen=CTGY&Store_Code=LTSO&Category_Code=MP4\'>Buy a Commuter Express Zone 4 Monthly Pass now.<\\/a><\\/strong><\\/p><\\/div>\";
}
else if(prodZ4 <= 0){
answerCemp.innerHTML=\"<div class=\'answerbox\'><h3>Your Results<\\/h3><p>Looks like you don\'t ride Commuter Express often enough to benefit from purchasing a Monthly Pass. Trip Tickets may be a better option for you. <strong><a href=\'#triptickets\'>Try the Trip Tickets Calculator below.<\\/a><\\/strong><\\/p><\\/div>\";
}
}
else if(selection == \"z3\"){
var prodZ3 = z3yearlyCash - 1488;
if(prodZ3 > 0){
answerCemp.innerHTML=\"<div class=\'answerbox\'><h3>Your Yearly Savings<\\/h3><p>If you pay cash, your yearly expense is $\" + z3yearlyCash + \".<br>Commuter Express Zone 3 Monthly Passes cost $1488 per year.<br><strong>That's a yearly savings of $\" + prodZ3 + \"!<\\/strong><br><strong><a href=\'http://store.ladottransit.com/Merchant2/merchant.mvc?Screen=PROD&Store_Code=LTSO&Product_Code=LADOTMPZ3&Category_Code=MP4\'>Buy A Commuter Express Zone 3 Monthly Pass Now<\\/a><\\/strong><\\/p><\\/div>\";
}
else if(prodZ3 <= 0){
answerCemp.innerHTML=\"<div class=\'answerbox\'><h3>Your Results<\\/h3><p>Looks like you don\'t ride Commuter Express often enough to benefit from purchasing a Monthly Pass. Trip Tickets may be a better option for you. <strong><a href=\'#triptickets\'>Try the Trip Tickets Calculator below.<\\/a><\\/strong><\\/p><\\/div>\";
}
}
else if(selection == \"z2\"){
var prodZ2 = z2yearlyCash - 1200;
if(prodZ2 > 0){
answerCemp.innerHTML=\"<div class=\'answerbox\'><h3>Your Yearly Savings<\\/h3><p>If you pay cash, your yearly expense is $\" + z2yearlyCash + \".<br>Commuter Express Zone 2 Monthly Passes cost $1200 per year.<br><strong>That's a a yearly savings of $\" + prodZ2 + \"<\\/strong>!<br><strong><a href=\'http://store.ladottransit.com/Merchant2/merchant.mvc?Screen=PROD&Store_Code=LTSO&Product_Code=LADOTMPZ2&Category_Code=MP4\'>Buy A Commuter Express Zone 2 Monthly Pass Now<\\/a><\\/strong><\\/p><\\/div>\";
}
else if(prodZ2 <= 0){
answerCemp.innerHTML=\"<div class=\'answerbox\'><h3>Your Results<\\/h3><p>Looks like you don\'t ride Commuter Express often enough to benefit from purchasing a Monthly Pass. Trip Tickets may be a better option for you. <strong><a href=\'#triptickets\'>Try the Trip Tickets Calculator below.<\\/a><\\/strong><\\/p><\\/div>\";
}
}
else if(selection == \"z1\"){
var prodZ1 = z1yearlyCash - 960;
if(prodZ1 > 0){
answerCemp.innerHTML=\"<div class=\'answerbox\'><h3>Your Yearly Savings<\\/h3><p>If you pay cash, your yearly expense is $\" + z1yearlyCash + \".<Br>Commuter Express Zone 1 Monthly Passes cost $960 per year.<br><strong>That's a yearly savings of $\" + prodZ1 + \"<\\/strong>!<br><strong><a href=\'http://store.ladottransit.com/Merchant2/merchant.mvc?Screen=PROD&Store_Code=LTSO&Product_Code=LADOTMPZ1&Category_Code=MP4\'>Buy A Commuter Express Zone 1 Monthly Pass Now<\\/a><\\/strong><\\/p><\\/div>\";
}
else if(prodZ1 <= 0){
answerCemp.innerHTML=\"<div class=\'answerbox\'><h3>Your Results<\\/h3><p>Looks like you don\'t ride Commuter Express often enough to benefit from purchasing a Monthly Pass. Trip Tickets may be a better option for you. <strong><a href=\'#triptickets\'>Try the Trip Tickets Calculator below.<\\/a><\\/strong><\\/p><\\/div>\";
}
}
else if(selection == \"Base\"){
var prodBase = baseyearlyCash - 684;
if(prodBase > 0){
answerCemp.innerHTML=\"<div class=\'answerbox\'><h3>Your Yearly Savings<\\/h3><p>If you pay cash, your yearly expense is $\" + baseyearlyCash + \".<br>Commuter Express Base Monthly Passes cost $684 per year.<br><strong>That's a yearly savings of $\" + prodBase + \"!<\\/strong><br><strong><a href=\'http://store.ladottransit.com/Merchant2/merchant.mvc?Screen=PROD&Store_Code=LTSO&Product_Code=LADOTMPB&Category_Code=MP4\'>Buy A Commuter Express Base Monthly Pass Now<\\/a><\\/strong><\\/p><\\/div>\";
}
else if(prodBase <= 0){
answerCemp.innerHTML=\"<div class=\'answerbox\'><h3>Your Results<\\/h3><p>Looks like you don\'t ride Commuter Express often enough to benefit from purchasing a Monthly Pass. Trip Tickets may be a better option for you. <strong><a href=\'#triptickets\'>Try the Trip Tickets Calculator below.<\\/a><\\/strong><\\/p><\\/div>\";
}
}
}
// End CE MP Savings Calc script -->
</script>
</head>
<body>
<form action=\"javascript:window.location = \'http://translate.google.com/translate?hl=en&sl=en&tl=\' + document.translateform.translate.value + \'&u=\' + window.location.href;\" method=\"get\" name=\"translateform\">
<label for=\"translate\">translate this page</label>
<select name=\"translate\" id=\"translate\">
<option value=\"es\">Spanish</option>
<option value=\"ar\">Arabic</option>
<option value=\"zh-CN\">Chinese Simplified</option>
<option value=\"zh-TW\">Chinese Traditional</option>
<option value=\"nl\">Dutch</option>
<option value=\"fr\">French</option>
<option value=\"de\">German</option>
<option value=\"el\">Greek</option>
<option value=\"it\">Italian</option>
<option value=\"ja\">Japanese</option>
<option value=\"ko\">Korean</option>
<option value=\"pt\">Portuguese</option>
<option value=\"ru\">Russian</option>
</select>
<div class=\"gobuttonwrapper\">
<input name=\"submit\" type=\"submit\" value=\"go\" class=\"gobutton\">
</div>
</form>
<div class=\"calcform\">
<form name=\"theForm3\">
<h2><a name=\"cemp\" id=\"cemp\"></a>You Do the Math: Commuter Express Monthly Pass Vs. Cash</h2>
<div class=\"calcform-content\">
<div class=\"formrow-calc\">
<div class=\"calcform-col1\">
<label for=\"trips-cemp\">Daily boardings on Commuter Express Bus*:</label>
<input type=\"text\" id=\"trips-cemp\">
</div><div class=\"calcform-col3\"></div>
</div>
<div class=\"formrow-calc\">
<div class=\"calcform-col1\">
<label for=\"days-cemp\">Days you ride Commuter Express <strong>per month</strong>:</label>
<input type=\"text\" id=\"days-cemp\"></div>
</div>
<div class=\"formrow-calc\">
<div class=\"calcform-col1\">
<label for=\"choosezone\">Choose Zone:</label>
<select name=\"zone\" id=\"choosezone\">
<option value=\"Base\">Base</option>
<option value=\"z1\">Zone 1</option>
<option value=\"z2\">Zone 2</option>
<option value=\"z3\">Zone 3</option>
<option value=\"z4\">Zone 4</option>
</select>
</div>
</div>
<div class=\"clear\"></div>
<div align=\"center\">
<button type=\"submit\" onclick=\"doMath3(); return false;\" class=\"btn-submit\"><img src=\"img/btn_savings.png\" alt=\"Show My Yearly Savings\"><br>
<img src=\"img/arrow_results.png\" alt=\"your results will display below\"></button>
</div>
</div>
</form>
<div id=\"answerCemp\"></div>
</div>
</body>
</html>
没有找到相关结果
已邀请:
1 个回复
际恃啸称桅