Answer the question
In order to leave comments, you need to log in
Google Translate form how to correct?
There is such a form - a question - I can’t change it so that the result of the translation
is in the same INPUT ,
please tell me
<html>
<body>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
</head>
<b>Text:</b> <input type="text" id="text" value="How are you"/> <br>
<b>Target Langugage:</b>
<select id="target">
<option value="de">Germany</option>
<option value="hi">Hindi</option>
<option value="fr">French</option>
</select>
<br>
<input type="button" value="Translate" onclick="translate()" /> <br> <br>
<b>Translated Text:</b><div id="translated"></div>
<script>
function translate()
{
$.get("https://www.googleapis.com/language/translate/v2",
{
key:"AIzaSyA8QSRDMjRvjJi__7nEk8ayrn3hmhFNRA8",
source:"en",
target:$("#target").val(),
q:$("#text").val()
},
function(response)
{
$("#translated").html(response.data.translations[0].translatedText);
},"json") .fail(function(jqXHR, textStatus, errorThrown)
{
alert( "error :"+errorThrown );
});
}
</script>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question