I am trying to call a JavaScript function with parameters via HTML button.
HTML:
<input id="clickMe" type="button" value="clickme" onclick="callFunc("<?php $x='Hello World'; echo $x; ?>")" />
JavaScript:
/*
* Convert string to a base-64 string
*/
function str2b64(input) {
try { b64pad } catch(e) { b64pad=''; }
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var output = "";
var len = input.length;
for(var i = 0; i < len; i += 3) {
var triplet = (input.charCodeAt(i) << 16)
| (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0)
| (i + 2 < len ? input.charCodeAt(i+2) : 0);
for(var j = 0; j < 4; j++) {
if(i * 8 + j * 6 > input.length * 8) output += b64pad;
else output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F);
}
}
alert(output);
}
What I get at run time or on click is absolutely NOTHING! As soon as I remove the variable I am passing it works as intended.
Not sure why I am having issues but regardless any help is greatly appreciated!
Thanks!