Solved

problem when passing a value with single quote

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

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

726 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