473,671 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to escape function call parameter

Hi,
I have a php function creating links from a products mysql database.
some of the descriptions have characters that I need to escape but
whatever i do, javascript doesn't like them.
for example a product description might be

30' black ribbon

I have tried backslash escapes and a php function, htmlspecialchar s
http://us3.php.net/htmlspecialchars

how should I escape the parameters?

Any help is appreciated,
Chuck

here is a basic example of what i am trying to do without success.

<script type="text/javascript">
function showValue(val)
{ document.getEle mentById('show' ).innerHTML = val;
return false;
}
</script>

<p><a href="#" onclick="return showValue('aaa' );">aaa</a></p>
<p><a href="#" onclick="return showValue('64"' );">64"</a></p>
<p><a href="#" onclick="return showValue('34\" ');">34"</a></p>
<p><a href="#" onclick="return showValue('&lt; a
href='test'&gt; Test&lt;/a&gt;');">&lt ;a
href='test'&gt; Test&lt;/a&gt;</a></p>
<div id="show"></div>
Nov 29 '05 #1
1 3488
You need to use standard unescape javascript function for your case.

<script type="text/javascript">
function showValue(val)
{ document.getEle mentById('show' ).innerHTML = unescape(val);
return false;
}
</script>

<a href="#" onclick="return
showValue('esca ped%20javascrip t%20string');"> </a>

Visit http://www.logicwebsolutions.com for a free copy of Logicweb
Studio, which has a lot of useful javascript examples

James

Nov 29 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
3690
by: Derek Hart | last post by:
I wish to execute code from a string. The string will have a function name, which will return a string: Dim a as string a = "MyFunctionName(param1, param2)" I have seen a ton of people discuss how reflection does this, but I cannot find the syntax to do this. I have tried several code example off of gotdotnet and other articles. Can somebody please show me the code to do this?
18
7180
by: Steve Litvack | last post by:
Hello, I have built an XMLDocument object instance and I get the following string when I examine the InnerXml property: <?xml version=\"1.0\"?><ROOT><UserData UserID=\"2282\"><Tag1 QID=\"55111\"><Tag2 AID=\"5511101\"></Tag2></Tag1><Tag1 QID=\"55112\"><Tag2 AID=\"5511217\"></Tag2></Tag1><Tag1 QID=\"5512282\"><Tag2 AID=\"551228206\"></Tag2></Tag1><Tag1 QID=\"55114\"><Tag2 AID=\"5511406\"></Tag2></Tag1><Tag1 QID=\"55115\"><Tag2
2
14472
by: Pavils Jurjans | last post by:
Hello, I am looking fow C# equivalent of JavaScripts escape() and unescape() functions. I need to use C# function at the server side and then be able to use the opposite at the client side. JavaScripts escape() function converts all non-alphanumerical chars to %xx, and all unicode chars to %uxxxx (where xxxx is unicode charcode). I'd like to have C# function that get this escaped string back to normal at the server side. Perhaps there...
12
9631
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" & Chr(34) & PopUpWindowTitle & Chr(34) & ", " & Chr(34) & CurrentEventDetails & ")" strTemp += "<BR><A HREF='#' onClick='" & PopupLink & "'>" & EventName & "</A><BR>" The problem I have is that when the string variables or contain a string with an...
4
1835
by: Vish | last post by:
Hi all, I am having a build error in one of the overloaded functions in my class. The function takes either a string as a parameter or a type referenced in another dll as a parameter. My class references the dll where the type of the parameter is defined. I am able to create to create my class in a form without any build errors and without any references to the DLL where the other parameter type is defined. The form only uses the...
11
407
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I can use dlopen/whatever to convert the function name into a pointer to that function, but actually calling it, with the right number of parameters, isn't easy. As far as I can see, there are only two solutions: 1) This one is portable. If...
131
9225
by: Lawrence D'Oliveiro | last post by:
The "escape" function in the "cgi" module escapes characters with special meanings in HTML. The ones that need escaping are '<', '&' and '"'. However, cgi.escape only escapes the quote character if you pass a second argument of True (the default is False): 'the "quick" &amp; &lt;brown&gt; fox' 'the &quot;quick&quot; &amp; &lt;brown&gt; fox' This seems to me to be dumb. The default option should be the safe one: that is, escape _all_ the potentially troublesome...
5
15677
by: vlsidesign | last post by:
The printf function returns "warning: unknown escape sequence: \040" for a backslash-space combination. If the ascii decimal number for space is 32 and the backslash is 92, why this particular number 040? Is it a decimal number from the ASCII code chart? (compiling using gcc on SunOS 5.8, Sparc, Ultra-80) Just curious. Thanks.
40
2337
by: Angus | last post by:
Hello I am writing a library which will write data to a user defined callback function. The function the user of my library will supply is: int (*callbackfunction)(const char*); In my libary do I create a function where user passes this callback function? How would I define the function?
0
8474
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8392
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8819
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8669
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7428
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5692
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2809
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2049
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.