0

I have a string file path that needs to be passed to jquery function this how it looks."3rd parameter on function viewDocument(extension,filename,filepath)"

<div onclick="viewDocument(doc,APPLICATION FOR POSITION OF HOW2 STUDENT LEADER,/Uploads/2018/Applicant_s219193029/documents/)" class="document info">         
  <div class="document-body">            
    <i class="fa fa-file-word-o text-info"></i>         
  </div>         
  <div class="document-footer">            
    <span class="document-name">APPLICATION FOR POSITION OF HOW2 STUDENT LEADER.doc </span>           <span class="document-description"> 53KB </span>         
  </div>     
</div>

I have been trying to modify with no luck.

2
  • 5
    I'd imagine that both the second and third parameters are supposed to be strings. Try wrapping them with single quotes instead: viewDocument(doc,'APPLICATION FOR POSITION OF HOW2 STUDENT LEADER','/Uploads/2018/Applicant_s219193029/documents/') Commented Nov 14, 2018 at 14:29
  • Yes, thanks guys its working, I forgot to mention the viewDocument() is in the js, but yes I was missing the quotes. Commented Nov 15, 2018 at 8:20

1 Answer 1

3

You can wrap them in Single Quotes ' in this case as the onclick function is surrounded with Double Quotes "

onclick= " viewDocument('doc','APPLICATION FOR POSITION OF HOW2 STUDENT LEADER','/Uploads/2018/Applicant_s219193029/documents/') "

Alternatively, with Double Quotes " if the function is wrapped with Single Quotes '

onclick= ' viewDocument("doc","APPLICATION FOR POSITION OF HOW2 STUDENT LEADER","/Uploads/2018/Applicant_s219193029/documents/") '

function viewDocument(extension,filename,filepath)
{
console.log(filepath);
}
<div onclick="viewDocument('doc','APPLICATION FOR POSITION OF HOW2 STUDENT LEADER','/Uploads/2018/Applicant_s219193029/documents/')" class="document info">         
  <div class="document-body">            
    <i class="fa fa-file-word-o text-info"></i>         
  </div>         
  <div class="document-footer">            
    <span class="document-name">APPLICATION FOR POSITION OF HOW2 STUDENT LEADER.doc </span>           <span class="document-description"> 53KB </span>         
  </div>     
</div>

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

2 Comments

In your given example, it should be single quotes only, as double quotes would cut the onclick short. As OP may be new to the subject, it could be important to mention this.
@cmprogram, ya maybe, I've described it a bit

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.