Hello,
I need to transliterate the names of employees that are fetched from my database and write the transliterated values back into the database... For this I need to run a javascript code in a loop for as many no of records as in the database....
The code I am currently using is
//CODE BEHIND
Dim cmd As New SqlCommand("select empname from tbl_emp", conobject)
Dim dr As SqlDataReader
conobject.Open()
dr = cmd.ExecuteReader
Dim i As Integer = 1
While dr.Read
Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "b" & i, "<script>conurdu('" & dr(0) & "');</script>")
Response.Write (txt_result.Text)
i = i + 1
End While
conobject.Close()
//JAVASCRIPT
<script type="text/javascript">
function conurdu(fieldname) {
google.language.transliterate([fieldname], "en", "ur", function(result) {
if (!result.error)
{
if (result.transliterations && result.transliterations.length > 0 && result.transliterations[0].transliteratedWords.length > 0)
{
document.getElementById(<%=txt_result.ClientID%>).value = result.transliterations[0].transliteratedWords[0] ;
}
}
});
}
</script>
For example, there are five records in the database, only the last one gets written in the txt_result textbox...
Any ideas???