Solved

javascript function

Posted on 2001-08-17
2
481 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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. …
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…

729 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