3
onclick="var searchb = jQuery('#'+searchBoxLinkId).value; 
var searchlink= window.location.protocol + '//' + window.location.hostname+'/Dave2/Pages/FAQSearch.aspx?category='+category+'&k='+searchb;
window.location = searchlink;" href="javascript: {}">

I have added this line of code to my javascript/html but it gives me the error Unterminated string constant however I cannot see where the problem is. I have to do it this way as I am doing something in sharepoint and it seems like this way is the only way it will work

4
  • you have some heavy typos in your code, check the double quotes Commented Sep 9, 2014 at 10:56
  • Look at the colors in the code above, and see if you can't spot it, it has something to do with the quotes. Commented Sep 9, 2014 at 10:56
  • because I am doing this in a sharepoint display template and as I have created my own function, it won't be defined in the ctx, so can't be run by just putting the function name Commented Sep 9, 2014 at 11:10
  • if you know how to do this in sharepoint please tell me Commented Sep 9, 2014 at 11:11

2 Answers 2

5

You do not set the searchBoxLinkId and category variables.

We assume some existing HTML (such as the snippet below) will set the two variables. In the code below, you can enter some variable into input and category is set to 11111. When you click on a tag, you redirect to that address.

<html>
<head>
    <title></title>
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript">
        var category=11111;
    </script>
</head>
<body>
    <input type="text" id="searchBoxLinkId"/>
    <a onclick="var searchb = jQuery('#searchBoxLinkId').val(); var searchlink= window.location.protocol + '//' + window.location.hostname+'/Dave2/Pages/FAQSearch.aspx?category='+category+'&k='+searchb;window.location.href = searchlink;" href="#">eee</a>

</body>

Sign up to request clarification or add additional context in comments.

Comments

0

You can use matching pairs of single or double quotation marks. Double quotation marks can be contained within strings surrounded by single quotation marks, and single quotation marks can be contained within strings surrounded by double quotation marks.

2 Comments

added some example it will be better for OP to understand
Actually rewriting the OP's code with the correct fixes would be best

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.