• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 493
  • Last Modified:

javascript function

Hi all,

Had this question pls..

I have a href link like:

a href="javascript:passback('<%=part%>','<%=option%>','<%=desc%>')"><%=part %></a>

where my javascript passback function looks like:

function passback(part,option,desc) {
 opener.document.osi.part_<%= request.getParameter("count") %>.value=part;
 opener.document.osi_oppy.option<%= request.getParameter("count") %>.value=option;
 opener.document.osi.desc_<%= request.getParameter("count") %>.value=desc;
}

Problem is:


My <%=option%> is returning string like :

---   6.5" value etc..   so it has quotes in it. Hence..

My javascript is showing an error as we cannot do this:

'6.5" value'   this is wrong..

could you kindly tell me How to fix this in a quick way so that I don't have to do much changes

Regards..
0
narrav
Asked:
narrav
1 Solution
 
webwomanCommented:
What values are in your database? If they have quotes in them, so will your javascript values.

Also, your numbers shouldn't be decimals -- they should be integers.
0
 
msdixonCommented:
first you will need to escape the quotes and other special characters. here's code for the server.

option = escapeJS(option)

function escapeJS(byval strVal)
     ' this one must be first
     strVal = replace(strVal, "\", "\\")
     strVal = replace(strVal, "'", "\'")
     strVal = replace(strVal, """", "\""")
     escapeJS = strVal
end function
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now