Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)

I ma using a javascript function to convert input Text of textbox in some other languges like HINDI,MARATHI etc.
but this function accepts only one languge statically.
so i want to give language code like "HINDI","MARATHI" from some other textbox value, but i cant get this language code from textbox and hence function is not working ,,so please do suggest proper way to give LanguagCode to the Function in javascript
Here is my code:
XML
<script language="javascript" type="text/javascript">
    google.load("elements", "1", {
        packages: "transliteration"
    });

    function onLoad() {
        
       value1 = document.getElementById('<%=txtLang.ClientID%>').value;
       
       var gt= $("#lblLang").text();
        //var gt = HINDI;
        //alert('language :', lang);
        var options = {

            sourceLanguage: google.elements.transliteration.LanguageCode.ENGLISH,
            destinationLanguage: google.elements.transliteration.LanguageCode.valueOf(value1), // available option English, Bengali, Marathi, Malayalam etc.
            shortcutKey: 'ctrl+g',
            transliterationEnabled: true
        };

        var control = new google.elements.transliteration.TransliterationControl(options);
        control.makeTransliteratable(['txtHindiContent']);
    }
    google.setOnLoadCallback(onLoad);

</script>



Design SIde:
XML
<table>
    <tr>
        <td>Type in Hindi : </td>
        <td>
            <asp:TextBox ID="txtHindiContent" runat="server" ClientIDMode="Static" TextMode="MultiLine" Height="100" Width="250"></asp:TextBox>
        </td>
    </tr>
    <tr>
        
        <asp:TextBox ID="txtLang" runat="server" Text="GUJARATI" xmlns:asp="#unknown"></asp:TextBox>
        <span id="spn" runat="server" title="HINDI"></span>
            </td>
        <td><asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" /></td>
    </tr>
Posted
Updated 11-Jul-14 20:30pm
v2

You are not calling your javascript function on page loading.So call that function on page loading like this..

HTML
<body  önload="onLoad()">
//Rest of the code
</body>


Happy Coding :-)
 
Share this answer
 
v2
Remove ClientIDMode="Static". or set ClientIDMode to AutoID

I think This will solve your problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900