Thanks for your helpful response!
Henry

On Oct 8, 6:40 am, "Jeremy R. Geerdes" <[EMAIL PROTECTED]> wrote:
> I've edited the code you provided to do what you desire.  Please note  
> that the code below willstorethe translation in a globalvariable 
> (i.e., accessible to the entire application).  The updatedvariable 
> will not be available until after the translation returns (i.e., there  
> could be a noticeable lag, so you can't use thevariableuntil after  
> translateResult runs).  And thevariablewill be overwritten with each  
> subsequent translation request.
>
> Jeremy R. Geerdes
> Effective website design & development
> Des Moines, IA
>
> For more information or a project quote:http://jgeerdes.home.mchsi.com
> [EMAIL PROTECTED]
>
> Unless otherwise noted, any price quotes contained within this  
> communication are given in US dollars.
>
> If you're in the Des Moines, IA, area, check out Debra Heights  
> Wesleyan Church!
>
> On Oct 7, 2008, at 10:28 PM, Henry wrote:
>
>
>
>
>
> > Hi,
> > I was wondering if anyone knew how to use google.language.translate
> > andstorethe result as a javascriptvariable.
> > As in the example given in the documentation:
>
> > function submitChange() {
> >      var text = document.getElementById('source').value;
> >      var dst = document.getElementById('dst').value;
> >      var src = "en";
> >      var result = document.getElementById("results_body");
> >      google.language.translate(text, src, dst, translateResult);
> >      return false;
> > }
>
> > function translateResult(result) {
> >      var resultBody = document.getElementById("results_body");
> >      if (result.translation) {
> >         // resultBody.innerHTML = result.translation; // we won't  
> > put the translation on the page
>
> window.myJSVar = result.translation;
>
> >      } else {
> >         // resultBody.innerHTML = '<span style="color:red">Error
> > Translating</span>'; // again, not putting the error on the page
>
> window.myJSVar = 'Error translating';
>
>
>
> >      }
> > }
>
> > I would like tostorethe translated text as a newvariablesuch as:
> > translatedText
>
> > Thanks,
> > Henry
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google AJAX API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-AJAX-Search-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to