Solved

Javascript single quot eissue

Posted on 2006-06-28
4
215 Views
Last Modified: 2008-03-03
Hello,

I have this function How do I get single quotes around the value.
          fixedFilterPart = 'owner_text='+document.all.ownerType.value;

Whatever value I get document.all.ownerType.value should be enclosed in single quotes

psl help


////////////////////////////////////////////////
function FilterOwner()
////////////////////////////////////////////////
{
      with (document.all.documentGrid)
      {
          alert(document.all.ownerType.value)
          if(document.all.ownerType.value=="")
          {
          fixedFilterPart=""
          }
          else
          {
          fixedFilterPart = 'owner_text='+document.all.ownerType.value;
          }
            
            loadData()
      }
}
0
Comment
Question by:sureshraina
  • 2
4 Comments
 
LVL 10

Expert Comment

by:0h4crying0utloud
ID: 17005215
this should work:

fixedFilterPart = "owner_text="+"'" + document.all.ownerType.value+ "'";
0
 
LVL 37

Accepted Solution

by:
Harisha M G earned 500 total points
ID: 17005216
fixedFilterPart = 'owner_text=\''+document.all.ownerType.value+'\'';
0
 
LVL 12

Expert Comment

by:netsmithcentral
ID: 17005223
Use \ before the ' to escape the character.

fixedFilterPart='owner_text=\''+document.all.ownerType.value+'\'';
0
 
LVL 37

Expert Comment

by:Harisha M G
ID: 17005250
suresh raina (?),

If you know C, then you will know about escape characters. In C, you'll use \' for single quotes and \" for double quotes.

In Javascript too, you need the same. But here, you don't need to escape single quote inside double quotes or double quote inside single quotes. What you need to escape is.. single quote inside single quotes and double quote inside double quotes.

So,
"'" is same as '\''
and
'"' is same as "\""



0

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Performance for Office 365 6 49
Why doesn't Google directions work? 6 46
How can i  prevent default  Submision? 6 27
Getting Random number with min and max value. 2 28
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
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…

809 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