Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JavaScript Function With a Parameter which contains Double quotes

Status
Not open for further replies.

Prashum

Technical User
Dec 20, 2004
4
US
Hi friends,

I have String which uses has Double quotes in it.

"LIGHT-FOR-DATES" WITHOUT MENTION OF FETAL MALNUTRITION,

The above string is to be used as a parameter to a JavScript function. But becoz of the double quotes.. it is not allowing me to do.. I appended the doublequotes with baclslash.. but of not use..

Can any one help me

Prashum
 
could you show us the code?


*cLFlaVA
----------------------------
[tt]insert funny quotation here.[/tt]
 
This is where i call the function using onclick:"sendValuesNew

<td width="10%"><a href="#" class="blueLinkSub" onclick="sendValuesNew('<%=vo.getCode()%>&nbsp;&nbsp;&nbsp;<%=CMSUtil.appendBackslash(vo.getDescription())%>');"><%=vo.getCode()%></a></td>

the string:
vo.getDescription() = "LIGHT-FOR-DATES" WITHOUT MENTION OF FETAL MALNUTRITION,

is causing a problem.. and the javascript function is not working
The Javascript function:

function sendValuesNew(numValNew) {
var mode = trim(document.frmNewWin.elements['mode'].value);

alert(" mode is " + mode);
if(mode == 1)
{
alert("This is a Javascript Alert1");


opener.document.forms[0].PrimDiag.value = numValNew;
opener.document.forms[0].PrimDiag1.value = numValNew;

}
if(mode == 2)
{
alert("This is a Javascript Alert2");

opener.document.forms[0].SecDiag.value = numValNew;
opener.document.forms[0].SecDiag1.value = numValNew;

}

window.close();
}

 
Before writing the character string with quotes in it to the event handler value, you'll either have to write a slash in front of each double quote (\"), or substitute &#34 for each one. It's not the Javascript as such that's causing the problem, it's having the quotation marks inside the other quotation marks.

Lee
 
Appending the double quotes with a backslash is not working...


 
Not append, PREPEND. Show the code that comes out on the page so we can see what the problem is.

Lee
 
ya.. i am sorry.. i meant prepend..

the code which comes after prepending the string with baclslashes is:

\"LIGHT-FOR-DATES\" WITHOUT MENTION OF FETAL MALNUTRITION,

Still this string when passed as a argument to the javascript function is causing problems
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top