<select name=lstMAName"+s+" onchange=showMAName(escape(this.value),"+s+")><option selected>- - -Select Account- - -</option> <%	for(j=0;j!=i;j++){%><option value=<%=MANAME[j]%>><%=MANAME[j]%></option><%}%></select>

In the above code i use escape, bcz in listbox i have to select on name, i have to send that name to showMAName function in another .js program, here iam getting problem that for example selected text is Adavance From Others, if there is any space in text, after space the text not getting like Advance only iam getting to the .js program, so for that i use esacpe & unescape but iam not getting properly plz tell me how to use here escape & unescape

function showMAName(str,str1)
{ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	alert(str1)
	alert(str)
	var str=unescape(str);
	alert(str)
var url="getSaname.jsp";
url=url+"?maname="+str+"&rowid="+str1;
document.getElementById("str").value=str1;
xmlHttp.onreadystatechange=stateChanged1;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged1() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		var str=document.inetform.str.value
		document.getElementById("lstSAName"+str).innerHTML=xmlHttp.responseText;
	}
}

Have you tried a standalone test case to make sure the problem is really with escape/unescape?

var escaped = escape("Advance to others");
var unescaped = unescape(escaped);
window.alert("Escaped: " + escaped + "\nUnescaped: " + unescaped);

Oh and BTW, use encodeURI / encodeURIComponent instead of escape since escape doesn't work well with non-ascii characters. MDC Reference.

hi thanx for ur reply
i run that standalone one it was working nice
and also run with encodeURI & decodeURI it was also working
but i use in my program it was not working
i think the problem is iam doing encode in one program and calling that ecoded variable in another program js and doing decode there so here iam getting problem already i send my program where iam using can u see again that and help me very urgent thanx

It doesn't matter if the string is escaped in one function and unescaped in another. Plus, using sever side code makes it impossible for us to reproduce the problem at our end. The only thing left for you is to use Firebug to debug your javascript code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.