Solved

problem when passing a value with single quote

Posted on 2006-06-14
3
215 Views
Last Modified: 2012-05-05
I have the following javascript in vb.net.  When NameStr has a single quote like, then it stop working.  How to fix ?  Thanks.

  jscript = "<script>window.opener.baseform.well_name.value='" & NameStr & "';opener.document.forms(0).submit(); opener.focus(); self.close();</script>"

0
Comment
Question by:ewang1205
  • 2
3 Comments
 
LVL 6

Expert Comment

by:pD_EO
ID: 16907659
Escape the quotes with a backslash?

I'm not familiar with vb.net, but a js example...

var myStr = 'string\'s with quote\'s';

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 16907790
Check this:

 jscript = "<script>window.opener.baseform.well_name.value='" & Replace(NameStr,"'","\'") & "';opener.document.forms(0).submit(); opener.focus(); self.close();</script>"

0
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 16908023
Better this:

 jscript = "<script>theForm=window.opener.document.baseform;theForm.well_name.value='" & Replace(NameStr,"'","\'") & "';theForm.submit(); opener.focus(); self.close();</script>"

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

821 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