• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

problem when passing a value with single quote

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
ewang1205
Asked:
ewang1205
  • 2
1 Solution
 
pD_EOCommented:
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
 
ZvonkoSystems architectCommented:
Check this:

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

0
 
ZvonkoSystems architectCommented:
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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now