Solved

problem when passing a value with single quote

Posted on 2006-06-14
3
213 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now