0

how could i open a new window using javascript inside php that holds a value of a js variable? please help. thx

4
Contributors
10
Replies
11
Views
5 Years
Discussion Span
Last Post by gerbz
0

I didn't understood much of what you said. But PHP cannot hold a JS var, PHP can only execute JS by writing it and JS can only execute PHP by a server request.

Is something like this you want?

<?php
    echo('<script type="text/string">window.open(....);</script>');
?>
0

I think so. Maybe he wants to use the variable in PHP as well. I believe, you can concatenate the variable to the string in the echo in order to pass the variable value to the new window.

0

sorry for that, i'm a newbie on php and on javascript my codes looks like this
$connect = mysql_connect("localhost","root","");
mysql_select_db("clarissa_records");
$query = mysql_query("
INSERT INTO reservation VALUES('','$fname','$email','$pnum','$numofperson','$numofroom','$roomtype','$cur_date','$time2','$date_value','$stay','pending','$tot2','$tot2','0')
");
i want to insert a javascript on this part opening a new window holding the value of variable $fname, tnx a lot..

0

in new page you can use php variable in javascript following way

<?php
.
.
.
$query = mysql_query("
INSERT INTO reservation VALUES('','$fname','$email','$pnum','$numofperson','$numofroom','$roomtype','$cur_date','$time2','$date_value','$stay','pending','$tot2','$tot2','0')
");
.
.
.

?>
<html>
<script lang='javascript' >
function myfunction()
{
   var firstnm="<?php echo $fname;?>";
  
   alert(firstnm);
   
}

</script>
0

I didn't understood much of what you said. But PHP cannot hold a JS var, PHP can only execute JS by writing it and JS can only execute PHP by a server request.

Is something like this you want?

<?php
    echo('<script type="text/string">window.open(....);</script>');
?>

yes sir exactly what i
want. :)

0

in new page you can use php variable in javascript following way

<?php
.
.
.
$query = mysql_query("
INSERT INTO reservation VALUES('','$fname','$email','$pnum','$numofperson','$numofroom','$roomtype','$cur_date','$time2','$date_value','$stay','pending','$tot2','$tot2','0')
");
.
.
.

?>
<html>
<script lang='javascript' >
function myfunction()
{
   var firstnm="<?php echo $fname;?>";
  
   alert(firstnm);
   
}

</script>

i want to insert the javascript inside my php code, opening a new window holding the value of php variable $fname

like this sir..

$connect = mysql_connect("localhost","root","");
mysql_select_db("clarissa_records");
$query = mysql_query("
INSERT INTO reservation VALUES('','$fname','$email','$pnum','$numofperson','$numofroom','$roomtype','$cur_date','$time2','$date_value','$stay','pending','$tot','$tot','0')
");
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<script language=javascript>alert($fname)</script>
<script language=javascript>window.location='reservation1.php'</script>";
}

0

&nbpsp; is not required its of no use, its only useful in html code, quote your fname around quotes.

<?php
.
.
.
echo "<script language=javascript>alert('$fname');
window.location='reservation1.php';</script>";
.
.

?>

Edited by urtrivedi: n/a

0

<script type="text/javascript">
<!--
function popup(url)
{
var date = "<?php echo $date1; ?>";
var width = 950;
var height = 750;
var left = (screen.width - width)/2;
var top = (screen.height - height)/2;
var params = 'width='+width+', height='+height;
params += ', top='+top+', left='+left;
params += ', directories=no';
params += ', location=no';
params += ', menubar=no';
params += ', resizable=no';
params += ', scrollbars=yes';
params += ', status=yes';
params += ', toolbar=no';
url = "printlist2.php?id="+date;
newwin=window.open(url,'windowname5', params);
if (window.focus) {newwin.focus()}
return false;
}
// -->
</script>

this is the javascript i want to insert inside my php code

0
var date = "<?php echo $date1; ?>";

I think this is the best way to access php in javascript. so you go ahead, I dont think you will get any problem in this.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.