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.
<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.
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.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.