Solved

javascript function

Posted on 2001-08-17
2
479 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
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…

713 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