I have surprised myself by successfully calling a PHP function from javascript
function clienttypechanged(){
var a=document.forms["myForm"]["thenametype"].value;
if (a=='1'){
document.getElementById('thepeople').innerHTML = "<?php pickpersons(1,1);?>";
}
if (a=='2'){
document.getElementById('thepeople').innerHTML = "<?php pickpersons(2,1);?>";
}
}
This works great but is limited to numbers.
What I am now trying to do is to insert the variable a into the php statement so that I do have to hard code as I add options.
I have tried concatenating to
document.getElementById('thepeople').innerHTML = "<?php pickpersons("+a+",1);?>";
I have also tried building up a string variable `thecode` and using
document.getElementById('thepeople').innerHTML = thecode;
But neither works - any suggestions please
function clienttypechanged(){
var a=document.forms["myForm"]["thenametype"].value;
if (a=='1'){
document.getElementById('thepeople').innerHTML = "<?php pickpersons(1,1);?>";
}
if (a=='2'){
document.getElementById('thepeople').innerHTML = "<?php pickpersons(2,1);?>";
}
}
This works great but is limited to numbers.
What I am now trying to do is to insert the variable a into the php statement so that I do have to hard code as I add options.
I have tried concatenating to
document.getElementById('thepeople').innerHTML = "<?php pickpersons("+a+",1);?>";
I have also tried building up a string variable `thecode` and using
document.getElementById('thepeople').innerHTML = thecode;
But neither works - any suggestions please