0

I'm using the linkedin JS-API

This example

I'm accepting the company name from the user. So, I want to build the <script> part of the above example programmatically. This is what I've done so far,

function companySearch()
{
   var companyName = document.getElementById("companyName").value;

   var searchHTML = "Search Results : ";


   searchHTML = searchHTML + "<p> The company details are as follows";
   searchHTML = searchHTML + "<script type=\"IN/CompanyProfile\" data-id=\"linkedin\" data-format=\"hover\"></script>";
   searchHTML = searchHTML + "</p>";

   document.getElementById("companyResult").innerHTML = searchHTML;
}

Markup:

    <script type="IN/Login"></script>
            <h1>
                LINKEDIN COMPANY SEARCH
            </h1>    

            <table>
                <tr>
                    <td>
                        Company Name :
                    </td>
                    <td>
                        <input type="Text" id="companyName" value=""/>
                    </td>
                    <td>

                    </td>
                    <td>
                        <input type="button" value="Search LinkedIn" onclick="companySearch()"/>
                    </td>
                </tr>
            </table>      


        <div id="companyResult">


        </div>

Output:

enter image description here

What is going wrong here?

0

1 Answer 1

2

You need to break up your script tags so the parser doesn't see them:

searchHTML = searchHTML + "<scr" + "ipt type=\"IN/CompanyProfile\" data-id=\"linkedin\" data-format=\"hover\"></scr" + "ipt>";
Sign up to request clarification or add additional context in comments.

1 Comment

You sir, have saved my life & time, thank you. Appreciate it.

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.