how could i open a new window using javascript inside php that holds a value of a js variable? please help. thx
gerbz 0 Newbie Poster
Recommended Answers
Jump to Postin 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>
Jump to Post&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>"; . . ?>
Jump to Postvar 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.
All 10 Replies
AleMonteiro 238 Can I pick my title?
Taywin 312 Posting Virtuoso
gerbz 0 Newbie Poster
urtrivedi 276 Nearly a Posting Virtuoso
gerbz 0 Newbie Poster
gerbz 0 Newbie Poster
urtrivedi 276 Nearly a Posting Virtuoso
gerbz 0 Newbie Poster
urtrivedi 276 Nearly a Posting Virtuoso
gerbz 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.