Solved

javascript function

Posted on 2001-08-17
2
474 Views
Last Modified: 2012-06-27
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
Comment
Question by:narrav
2 Comments
 
LVL 19

Accepted Solution

by:
webwoman earned 110 total points
Comment Utility
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
 
LVL 9

Expert Comment

by:msdixon
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now