Solved

javascript function

Posted on 2001-08-17
2
478 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
ID: 6398507
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
ID: 6398697
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

829 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