unicode support in javascript

unicode support in javascript

View Answers

October 17, 2008 at 4:18 PM

Hi friend,



Please give the full details and source code to solve the problem.


Thanks

October 17, 2008 at 5:02 PM

We are holding all data in java scripts object , .

Here sample code here,


<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>


//

We have removed server side code from , That is not related with above mentioned problem..
After fetching data from server we displaying in the text field and mpdifying content
content is accumulating junk value in the text field before sending to server functionality


We are already using encodingfor jsp


1)and client side page
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>

2)
(<meta http-equiv="Content-Type" content="text/html; charset=windows-874" /> (taken from Hutch--check it http://www.hutch.co.th/index_th.htm)

we have alrready tried <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<!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=windows-874" />

<script language="JavaScript" src="common/FormFillValidation.js" type="text/javascript"></script>
<script language="JavaScript" src="common/sortTable.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
parent.document.frmFill.allUploadCodes.value = '<%=allUploadCodes%>';
parent.document.frmFill.allContentNames.value = '<%=allContentNames%>';
parent.document.frmFill.contentId.value = '<%=contentId%>';


function actorChange(){
var selActor =document.frmBuffer.cmbactors[document.frmBuffer.cmbactors.selectedIndex].value;
if (selActor == -1) {
popitup('popup/NewActor.jsp');}
}
function artistChange(){
var selArtist =document.frmBuffer.cmbartists[document.frmBuffer.cmbartists.selectedIndex].value;
if (selArtist == -1){
popitup('popup/NewArtist.jsp');}
if (selArtist == -2){
window.open('popup/CoArtists.jsp','name','height=400,width=500');
//popitup('popup/CoArtists.jsp');
}
}
function movieChange(){
var selMovie =document.frmBuffer.cmbmovies[document.frmBuffer.cmbmovies.selectedIndex].value;
if (selMovie == -1){
popitup('popup/NewMovie.jsp');}
}
function chkUpdate(chk, len ){
document.frmBuffer.chkValue.value = chk ;
var nchk = eval('document.frmBuffer.chkBufedit'+chk);
var i = 0;
for (i=0 ; i< len ; i++ )
{
if (i != chk ){
nchk = eval('document.frmBuffer.chkBufedit'+i);
if (nchk.checked){
//alert("Releasing other checks");
nchk.click();
}
}
}
}

// validate and add the Content details to the buffer
function add(){
document.frmBuffer.pageType.value = "addVar";
document.frmBuffer.action = "BatchEdit_Bottom.jsp";
document.frmBuffer.submit();

}

//Clears the Buffer
function clearBuff(){
document.frmBuffer.pageType.value = "clrbuf";
document.frmBuffer.action = "BatchEdit_Bottom.jsp";
document.frmBuffer.submit();
}

//Upload the buffer
function uploadBuff(){
if(<%=batchUpdateFlag%> == true){
document.frmBuffer.pageType.value = "batchUpdate";
}
else{
//alert("NEW upload");
document.frmBuffer.pageType.value = "upload";
}
document.frmBuffer.action = "BatchEdit_Bottom.jsp";
document.frmBuffer.submit();
}

function removeTone(){
//code modyfied by .P on 2/7/2007
var cnf="false";
var bsize=document.getElementById("txtbufsize").value;
var h = 0;
for(h=0;h<bsize;h++)
{
if(eval('document.frmBuffer.chkBufedit'+h).checked == true)
{
cnf=true;
}
}
if (cnf==true){
document.frmBuffer.pageType.value = "remove";
document.frmBuffer.action = "BatchEdit_Bottom.jsp";
document.frmBuffer.submit();
}else
{
alert('Please select the checkbox!!');
}
}
function editTone(){
var cnf="false";
var bsize=document.getElementById("txtbufsize").value;
var h = 0;
for(h=0;h<bsize;h++)
{
if(eval('document.frmBuffer.chkBufedit'+h).checked == true)
{
cnf=true;
}
}
if (cnf==true){
document.frmBuffer.pageType.value = "edit";
document.frmBuffer.action = "BatchEdit_Bottom.jsp?txtaddeditvalue=1";
document.frmBuffer.submit();
}else
{
alert('Please select the checkbox!!');
}

}
function updateItem(){

document.frmBuffer.pageType.value = "update";
document.frmBuffer.chkValue.value = '<%=editIndx%>';
//alert( <%=editIndx%> );
document.frmBuffer.action = "BatchEdit_Bottom.jsp";
document.frmBuffer.submit();

}
</script>


</head>
<body onLoad='initTable("tblBuffer");' topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">
<form name="frmBuffer" method="POST" action="">
<input type="hidden" name="chkValue" value="-1">
<input type="hidden" name="pageType" value=" ">
<input type="hidden" name="batchId" value="<%=curBatchId%>">
<input type="hidden" name="uploadDate" value="<%=currentDate%>">
<input type="hidden" name="isUploadcodeUnique" value="false">

<input type="hidden" name="txtbufsize" value="<%=Bufsize%>">
<input type="hidden" name="txtaddeditvalue" value="<%=addeditflag%>">

<div align="center">

<table border="0" width="100%" cellpadding="0" valign="top" cellspacing="0">
<tr>
<td>
<div style="width:100%;">
<table border="0" width="100%" bgcolor="#FAEBD7" ID="tblBuffer">
<tr>
<td bgcolor="#C0C0C0" width="4%"><font style="verdana" size="2"><b>S no.</b></font></td>
<td bgcolor="#C0C0C0" width="10%"><font style="verdana" size="2"><b>Content Id</b></font></td>
<td bgcolor="#C0C0C0" width="13%"><font style="verdana" size="2"><b>Upload Filename</b></font></td>
<td bgcolor="#C0C0C0" width="13%"><font style="verdana" size="2"><b>ContentName</b></font></td>
<td bgcolor="#C0C0C0" width="13%"><font style="verdana" size="2"><b>Movie/Album Name</b></font></td>
<td bgcolor="#C0C0C0" width="13%"><font style="verdana" size="2"><b>Artists</b></font></td>
<td bgcolor="#C0C0C0" width="13%"><font style="verdana" size="2"><b>Content Type</b></font></td>
<td bgcolor="#C0C0C0" width="13%"><font style="verdana" size="2"><b>Song Name</b></font></td>
<td bgcolor="#C0C0C0" width="12%">
<input type="button" value="Edit" onClick="javascript:editTone()" name="btnBufedit" style="border: 2px ridge #FFFFFF; background-color:#C0C0C0; color:#FFFFFF; width:100%; height:20; font-weight:bold">
<bgcolor="#C0C0C0">
<!-- <input type="button" value="Del" onClick="javascript:removeTone()" name="btnBufDelete" style="border: 3px ridge #FFFFFF; background-color:#C0C0C0; color:#FFFFFF; width:45%; height:25; font-weight:bold"> -->
</td>
</tr>
<% if (bufferVec != null){
for (int i=0;i<bufferVec.size();i++)
{
uploaditem tnDtl = (uploaditem) bufferVec.elementAt(i);
String chkClick = "javascript:chkUpdate('"+ i +"','" + bufferVec.size()+"')";
Bufsize=bufferVec.size();

%>
<tr>
<td border="1" width="4%"><font color="#000000"><%=i+1%></font></td>
<td border="1" width="5%"><font color="#000000"><%=tnDtl.toneId%></font></td>
<td border="1" width="5%"><font color="#000000"><%=tnDtl.uploadcode%></font></td>
<td border="1" width="15%"><font color="#000000"><%=tnDtl.toneName%></font></td>
<td width="15%"><font color="#000000"><%=tnDtl.albumName%></font></td>
<td width="15%"><font color="#000000"><%=tnDtl.artistName%></font></td>
<td width="15%"><font color="#000000"><%=tnDtl.toneTypeName%></font></td>
<td width="15%"><font color="#000000"><%=tnDtl.songName%></font></td>

<% if (editFlag == true){
if (i == editIndx ){%>
<td width="12%"><input disabled checked type="checkbox" value="<%=i%>" onClick="<%=chkClick%>" name="chkBufedit<%=i%>"></td>
<%}}else{%>
<td width="12%"><input type="checkbox" value="<%=i%>" onClick="<%=chkClick%>" name="chkBufedit<%=i%>"></td>
<%}%>
</tr>
<%}%>
<%}%>
<tr>
<% if (upStatus == true ){%>
<font color="#FFFFFF"> </font>
<td align="center"><b><font size="4">Content Upload Success</font></b><font size="4"> </font></td>
<script type="text/javascript">
parent.location.href = "AddFiles.jsp";
</script>
<%}%>
<% if (editFlag == true ){%>
<script type="text/javascript">
document.frmBuffer.btnBufedit.disabled = true ;
//document.frmBuffer.btnBufDelete.disabled = true ;
</script>
<%}%>
</tr>
</table>
<%

if(editFlag==true)
{%>
<input type="hidden" name="txtcode" value="<%=editTn.uploadcode%>">
<input type="hidden" name="txttonname" value="<%=editTn.toneName%>">
<input type="hidden" name="cmbmovies" value="<%=editTn.albumId+"|"+editTn.albumName%>">
<input type="hidden" name="cmbartists" value="<%=editTn.artistId+"|"+editTn.artistName%>">
<input type="hidden" name="hdcoArtists" value="<%=editTn.coactorId%>">
<input type="hidden" name="cmbactors" value="<%=editTn.actorId+"|"+editTn.actorName%>">
<input type="hidden" name="terrSubpubStr" value="<%=editTn.terrSubpubString%>">
<input type="hidden" name="cmbtonetype" value="<%=editTn.toneTypeId+"|"+editTn.toneTypeName%>">
<input type ="hidden" name="newcontent" value="0">
<input type="hidden" name="cmbSong" value="<%=editTn.songId+"|"+editTn.songName%>">
<input type="hidden" name="lyrics" value="<%=editTn.songLyrics%>">
<input type="hidden" name="txtsongcode" value="<%=editTn.songCode%>">
<!-- Added by Jay for bringing publisher in Main Page -->
<input type="hidden" name="cmbPublisherInMainPage" value="<%=editTn.publisherId%>">
<input type="hidden" name="cmbprice" value="<%=editTn.priceType%>">
<input type="hidden" name="txtcredits" value="<%=editTn.credits%>">
<script>
//now change the values in the form
parent.fillForm();
</script>
<%}else{%>
<input type="hidden" name="txtcode" value="">
<input type="hidden" name="txttonname" value="">
<input type="hidden" name="cmbmovies" value="">
<input type="hidden" name="cmbartists" value="">
<input type="hidden" name="hdcoArtists" value="">
<input type="hidden" name="cmbactors" value="">
<input type="hidden" name="terrSubpubStr" value="">
<input type="hidden" name="cmbtonetype" value="">
<input type="hidden" name="cmbSong" value="">
<input type="hidden" name="lyrics" value="">
<!-- Added by Jay for bringing publisher in Main Page -->
<input type="hidden" name="cmbPublisherInMainPage" value="">
<input type="hidden" name="cmbprice" value="">
<input type="hidden" name="txtcredits" value="">

<%}%>

<script>
document.frmBuffer.txtbufsize.value='<%=Bufsize%>';
//code added by .P on 09/01/2007
if(parent.document.frmFill.btnBufUplaod.disabled == true){
uploadBuff();
document.frmBuffer.txtaddeditvalue.value=="0"
}
</script>

</form>
</div>
</body>
</html>










Related Tutorials/Questions & Answers:

Ads