| | |
Arguments of a function
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Greetings.
I encountered this little problem and am stuck. I don't know what should I google. I am developing a webpage with Coldfusion and I need to use some Javascript also.
I have a component, and onclick of that component, I would like to call a Javascript function and pass in some arguments - the arguments are gotten from some Coldfusion variables. I have made the function to run, but at the time of coding, I did not thought of this problem. So here it a little snippet.
The above code is just something similar to my program. That snippet works. But, if I pass in arguments[1] as 'this is hm's program' then the program fails. That is because of the ' symbol there. The error says, "expected )". I can't figure out what should I do to escape that.
Please advise.
I encountered this little problem and am stuck. I don't know what should I google. I am developing a webpage with Coldfusion and I need to use some Javascript also.
I have a component, and onclick of that component, I would like to call a Javascript function and pass in some arguments - the arguments are gotten from some Coldfusion variables. I have made the function to run, but at the time of coding, I did not thought of this problem. So here it a little snippet.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<!-- html --> <input type="button" value="Click me" onClick="sortTable(0, 'abcdef')"> <script> function sortTable(arg1){ if(sortTable.arguments.length > 1) alert(sortTable.arguments[1]); } </script>
The above code is just something similar to my program. That snippet works. But, if I pass in arguments[1] as 'this is hm's program' then the program fails. That is because of the ' symbol there. The error says, "expected )". I can't figure out what should I do to escape that.
Please advise.
"Study the past if you would define the future" - Confucius
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
Use double quotes around your string:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
"this is hm's program"
you can also escape the character using a backslash... this way you can be sure that your arguments will be interpreted correctly... especially true if your page is being generated.
the reason i like escaping these characters is i then know thatit will be safe using any javascript string syntax.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
"this is hm\'s program"
the reason i like escaping these characters is i then know thatit will be safe using any javascript string syntax.
![]() |
Similar Threads
- too many arguments to function error message. (C++)
- error: too many arguments to function `mysql_query' (C)
- Function calls in C++ (C++)
- arguments in function (C)
Other Threads in the JavaScript / DHTML / AJAX Forum
| Thread Tools | Search this Thread |
acid2 ajax ajaxexample ajaxjspservlets array browser bug captchaformproblem cart checkbox child class close codes createrange() css cursor date debugger decimal dependent design disablefirebug dom dropdown editor element embed engine enter error events explorer ext file firefox focus form forms frameworks getselection google gxt hiddenvalue highlightedword hint html ie7 ie8 iframe images index internet java javascript javascripthelp2020 jquery jsf jsfile jsp jump libcurl listbox maps masterpage math media menu mp4 object onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php position post problem programming progressbar prototype redirect runtime safari scale scriptlets scroll search security shopping size software toggle unicode w3c web wysiwyg \n






