Passing path string to a jquery function










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.










share|improve this question



















  • 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/')

    – Tyler Roper
    Nov 14 '18 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.

    – Anele Ngqandu
    Nov 15 '18 at 8:20















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.










share|improve this question



















  • 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/')

    – Tyler Roper
    Nov 14 '18 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.

    – Anele Ngqandu
    Nov 15 '18 at 8:20













0












0








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.










share|improve this question
















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.







jquery html






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 14:52









James Z

11.2k71935




11.2k71935










asked Nov 14 '18 at 14:28









Anele NgqanduAnele Ngqandu

357




357







  • 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/')

    – Tyler Roper
    Nov 14 '18 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.

    – Anele Ngqandu
    Nov 15 '18 at 8:20












  • 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/')

    – Tyler Roper
    Nov 14 '18 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.

    – Anele Ngqandu
    Nov 15 '18 at 8:20







5




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/')

– Tyler Roper
Nov 14 '18 at 14:29





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/')

– Tyler Roper
Nov 14 '18 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.

– Anele Ngqandu
Nov 15 '18 at 8:20





Yes, thanks guys its working, I forgot to mention the viewDocument() is in the js, but yes I was missing the quotes.

– Anele Ngqandu
Nov 15 '18 at 8:20












1 Answer
1






active

oldest

votes


















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>








share|improve this answer

























  • 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
    Nov 14 '18 at 14:41











  • @cmprogram, ya maybe, I've described it a bit

    – mbharanidharan88
    Nov 14 '18 at 14:47






  • 1





    That's awesome +1

    – cmprogram
    Nov 14 '18 at 14:49










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53302515%2fpassing-path-string-to-a-jquery-function%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









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>








share|improve this answer

























  • 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
    Nov 14 '18 at 14:41











  • @cmprogram, ya maybe, I've described it a bit

    – mbharanidharan88
    Nov 14 '18 at 14:47






  • 1





    That's awesome +1

    – cmprogram
    Nov 14 '18 at 14:49















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>








share|improve this answer

























  • 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
    Nov 14 '18 at 14:41











  • @cmprogram, ya maybe, I've described it a bit

    – mbharanidharan88
    Nov 14 '18 at 14:47






  • 1





    That's awesome +1

    – cmprogram
    Nov 14 '18 at 14:49













3












3








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>








share|improve this answer















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>








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>





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>






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 14 '18 at 14:46

























answered Nov 14 '18 at 14:35









mbharanidharan88mbharanidharan88

4,05942455




4,05942455












  • 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
    Nov 14 '18 at 14:41











  • @cmprogram, ya maybe, I've described it a bit

    – mbharanidharan88
    Nov 14 '18 at 14:47






  • 1





    That's awesome +1

    – cmprogram
    Nov 14 '18 at 14:49

















  • 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
    Nov 14 '18 at 14:41











  • @cmprogram, ya maybe, I've described it a bit

    – mbharanidharan88
    Nov 14 '18 at 14:47






  • 1





    That's awesome +1

    – cmprogram
    Nov 14 '18 at 14:49
















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
Nov 14 '18 at 14:41





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
Nov 14 '18 at 14:41













@cmprogram, ya maybe, I've described it a bit

– mbharanidharan88
Nov 14 '18 at 14:47





@cmprogram, ya maybe, I've described it a bit

– mbharanidharan88
Nov 14 '18 at 14:47




1




1





That's awesome +1

– cmprogram
Nov 14 '18 at 14:49





That's awesome +1

– cmprogram
Nov 14 '18 at 14:49



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53302515%2fpassing-path-string-to-a-jquery-function%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3