How to pass a string to the Javascript function from HTML?

Karunagara

I have a dynamic Html table in which there is a cell that contains anchor tag. Along with the anchor tag, I'm calling a function thru OnClick method. That function takes two parameter and both are String type.

In that, one string contains the value like this "PUT Request|GET Request|JDBC Request|"

Example:

<td align='center'><a href='#' title='click here' onclick=showTestCaseReport('" 
+ tcId + "','" + strStep + "')>Detail</a></td>

JavaScript function:

function showTestCaseReport(testCaseId, testSteps)
{
    alert(testCaseId);
    alert(testSteps);
}

But when click on the click i.e. Detail from the browser, Javascript alert is not displaying as per the function defined.

EDITED: After analysed, I came to know that the String value that I had mentioned above has white space in the middle. After removing the white spaces like this PUTRequest|GETRequest|JDBCRequest|, its working.

Ques: Is there any way to handle this without removing the white space in the middle of the string values?

Thanks

Abhishek Mathur

Your onclick attribute is missing quotes please add them correctly and proceed See this https://jsbin.com/viqosobizo/edit?html,output

<td align='center'><a href='#' title='click here' onclick="showTestCaseReport('hello','great');">Detail</a></td>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to pass Javascript as a string to function from HTML

From Dev

How to pass comma separate string in JavaScript function from Code behind?

From Dev

How to pass xml string from .cs file to javascript function?

From Dev

How to pass comma separate string in JavaScript function from Code behind?

From Dev

How to pass custom string in JavaScript function from code behind in?

From Dev

How to pass parameters to JavaScript Function From Generated HTML

From Dev

Javascript will not pass information into function from html

From Dev

Android: Pass html string from java to javascript

From Dev

how to pass string in onclick function html

From Dev

How to pass search string to javascript from javascript?

From Dev

How to pass a string as an argument to a javascript function

From Dev

How to pass String Variable in Javascript Function?

From Dev

How to pass a string as argument JavaScript function?

From Dev

How to pass String Argument to javascript function

From Dev

How to pass a HTML control to another javascript function

From Dev

How to pass a variable in javascript to an HTML string

From Dev

How to pass a queryset from django to javascript function?

From Dev

How to pass parameters from async function in javascript?

From Dev

How to pass parameter to XSLT from Javascript function

From Dev

How to pass images from server to function in JavaScript?

From Dev

How to pass values from javascript to html?

From Dev

How to pass an array from HTML to Javascript?

From Dev

JavaScript function not retrieving string from HTML textarea

From Dev

How to Pass a String in a function?

From Dev

Pass a string with double and single quotes from asp to javascript function

From Dev

Pass multiple string values as parameter from server side to javascript function

From Dev

HTML get input from textarea and pass it to my Javascript function

From Dev

Pass multiline html string(markdown text) from rails to javascript

From Dev

Pass HTML element to JavaScript function

Related Related

  1. 1

    How to pass Javascript as a string to function from HTML

  2. 2

    How to pass comma separate string in JavaScript function from Code behind?

  3. 3

    How to pass xml string from .cs file to javascript function?

  4. 4

    How to pass comma separate string in JavaScript function from Code behind?

  5. 5

    How to pass custom string in JavaScript function from code behind in?

  6. 6

    How to pass parameters to JavaScript Function From Generated HTML

  7. 7

    Javascript will not pass information into function from html

  8. 8

    Android: Pass html string from java to javascript

  9. 9

    how to pass string in onclick function html

  10. 10

    How to pass search string to javascript from javascript?

  11. 11

    How to pass a string as an argument to a javascript function

  12. 12

    How to pass String Variable in Javascript Function?

  13. 13

    How to pass a string as argument JavaScript function?

  14. 14

    How to pass String Argument to javascript function

  15. 15

    How to pass a HTML control to another javascript function

  16. 16

    How to pass a variable in javascript to an HTML string

  17. 17

    How to pass a queryset from django to javascript function?

  18. 18

    How to pass parameters from async function in javascript?

  19. 19

    How to pass parameter to XSLT from Javascript function

  20. 20

    How to pass images from server to function in JavaScript?

  21. 21

    How to pass values from javascript to html?

  22. 22

    How to pass an array from HTML to Javascript?

  23. 23

    JavaScript function not retrieving string from HTML textarea

  24. 24

    How to Pass a String in a function?

  25. 25

    Pass a string with double and single quotes from asp to javascript function

  26. 26

    Pass multiple string values as parameter from server side to javascript function

  27. 27

    HTML get input from textarea and pass it to my Javascript function

  28. 28

    Pass multiline html string(markdown text) from rails to javascript

  29. 29

    Pass HTML element to JavaScript function

HotTag

Archive