i would like to pass PHP code through JS, because I want to change dynamically the HTML attribute.
I have a problem with echoing string. I know why I have the problem(i think), but I don't know how to deal with it.
<?php echo $string1; ?>
the number "1" in code above had to be dynamic, based on ID of clicked link. This is code I have
<script>
$(function(){
$('#myTab a').click(function (e) {
e.preventDefault()
$(this).tab('show')
alert(this.id)
var complete = ''.concat('<?php echo $string', this.id, '; ?>');
document.getElementsByName('amount')[0].value=complete;
})
});
</script>
and it returns me error:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in
I know that the error is because of the part with '
please, don't ask why I'm trying to do this any that i shouldn't create strings like that, i just wanna help with existing code i have.
thanks!