This is a Flex cum Js cum JSP issue.
I want to pass a string variable containing ampersand ('&') character onto a URL through javascript but my string gets stripped when it encounters the first '&' in it !!!
I have an array of strings which get passed from an mxml file or method call as below:
Code in my mxml file:
noOfCols=4
rowData is an array with 5 strings passed:
"12-34"
"56-78"
"12-90"
"ABC & CO &RODGER"
"1234"
ExternalInterface.call("funToOpenPopUpWindow",columns,rowData,noOfCols)
Code inside my js file:
function funToOpenPopUpWindow(columns,rowData,noOfCols){
var j=0;
var RowElements=new Array();
RowElements="";
while(j<noOfCols)
{
if(rowData[j]== "" || rowData[j] == null){
RowElements+="BLANK";
}
else{
alert("hi 2"+rowData[j])
//rowData[j] = rowData[j].replace("&","%26") // This is what I am stuck at what to do?
//rowData[j] = rowData[j].replaceAll('&','/&') //I dont know if its right
RowElements+=rowData[j];
alert(RowElements)
}
RowElements+="@";
j++;
}
var url="popUp.action";
var popup =url+"cols="+cols+"&RowElements="+RowElements;
window.showModalDialog(popup, self,"dialogHeight:700px;dialogWidth:600px, resizable=no ,scrollbars=no");
}
I am not able to pass the character '&' inside the string "ABC & CO &RODGER" as '&' ,Actually as soon as it sees '&' in the string when while loop reaches rowData[3] ,it stops at 'ABC ' and doesnt go beyond that.I am not finding whats the issue with display of '&' in the string being passed,I need to pass this string and append '@' to it and then pass it as a parameter to the URL inorder to open a new window.
Please help me fix this !
I tried the replace method for strings in Javascript but it could not work.
>