I have the following question in my PHP survey form:

As can be seen in the image, when user select "By actor", a textbox appears(I uses jQuery auto-completion for this). Then, what I need is when user click the button "Movies by this actor", a list of movies by this actor (in this case: Tom Hanks), will be shown in a new window.
In order to get movies by the actor that user has inserted in the textbox, first, I have to
be able to access selectedVal in child window. Then, I have to run a database query to get all movies by selectedVal(actor name in the textbox).
This is my code:
<html>
<body>
<div id="m_scents2" class="field2" style="display:none;">
<input type="textbox" name= "tag" id="tags" placeholder="Enter an actor/actress name here" />
<input type="button" value="Movies by this actor" id="btnRight" />
</div>
<script type="text/javascript">
var selectedVal;
$(document).ready(function () {
// ...
//..
if ($(this).val() == "byActor"){
$("#tags").focus();
$("#tags").autocomplete({
source: "actorsauto.php",
minLength: 2,
focus: function( event, ui ){
event.preventDefault();
return false;
},
select: function (event, ui){
window.selectedVal = ui.item.value;
}
});
});
$('#btnRight').on('click', function (e) {
popupCenter("movieByactor.php","_blank","400","400");
});
</script>
</body>
</html>
and this is child window (movieByactor.php):
<script type="text/javascript">
var selectedVal = parent.window.opener.selectedVal;
$.ajax({
url: 'childfilm.php', //childfilm.php IS A PHP FILE WHERE I RUN SQL QUERY TO GET MOVIES BY THE ACTOR ...
datatype: "json",
data:{q:selectedVal},
success: function(response) {
alert(JSON.stringify(response));
}
});
</script>
My question:
Now my question is how can I use php inside javascript? I know that php is server side while javascript is client. I read lots of similar questions and I used ajax, but with the above code, when I click on the button, a new window appears but it is empty.
I really appreciate if someone can help me.
Thanks in advance,
childfilm.phpin quotes, you're using it as if it's a variable at the moment, not a string literal. It should look likeurl: "childfilm.php",url: 'childfilm.php',in an edit. You should always make note that an edit has been made to that effect. People giving answers may get downvoted because of it, when people will see your question and say to themselves: "There's quotes in there, why the answer?".