php and javascript

This is a discussion on "php and javascript" within the JavaScript Forum section. This forum, and the thread "php and javascript are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Mar 6th, 2007, 03:09
New Member
Join Date: Feb 2007
Location: Cebu City Philippines
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
php and javascript

hi please help, i am trying to embed javascript with php but it doesn't work. Want i want to happen is to check on the javascript script first if javascript is not available then php header function should be called can somebody correct this code

<script language="JavaScript" type="text/javascript">
if(window.opener){
opener.location.reload(true);
self.close();
}

else{

<?php header('location:index.php');?>
}

</script>';
Reply With Quote

  #2 (permalink)  
Old Mar 6th, 2007, 06:10
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php and javascript

You cannot put PHP inside JavaScript, only the other way around. JavaScript is client side, so the PHP will never get parsed.
Reply With Quote
  #3 (permalink)  
Old Mar 6th, 2007, 06:26
New Member
Join Date: Feb 2007
Location: Cebu City Philippines
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php and javascript

Thanks for that info ryan do you have any suggestion on how will i get around this problem? i would like to close the child window and refresh the parent window if the query is successful. that is if the client has javascript enable if javascript is not available i want to redirect the user back to the parent window.
Reply With Quote
  #4 (permalink)  
Old Mar 6th, 2007, 11:28
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php and javascript

Use window.location() to redirect the browser.
Reply With Quote
  #5 (permalink)  
Old Mar 6th, 2007, 23:29
New Member
Join Date: Feb 2007
Location: Cebu City Philippines
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php and javascript

Thanks again ryan
Reply With Quote
  #6 (permalink)  
Old Mar 7th, 2007, 00:34
New Member
Join Date: Feb 2007
Location: Cebu City Philippines
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php and javascript

Hi ryan, i tried using window.location but it didn't work here's how i did it

<script language="javascript" type="text/javascript">
if(window.opener){
opener.location.reload=true;
self.close;

}
else{
window.location="index.php";
}
</script>
Reply With Quote
  #7 (permalink)  
Old Mar 10th, 2007, 15:50
New Member
Join Date: Mar 2007
Location: Nelson, BC -- Canada
Age: 41
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php and javascript

Why use javascript at all then? If you're going to use PHP anyways, leave out the javascript, and no one will know the difference.

try using window.close instead of self.close
Reply With Quote
  #8 (permalink)  
Old Mar 14th, 2007, 08:22
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php and javascript

JavaScript is an awesome language. Used with PHP, the combination is almost unstoppable.
Reply With Quote
  #9 (permalink)  
Old Mar 14th, 2007, 23:18
New Member
Join Date: Feb 2007
Location: Cebu City Philippines
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php and javascript

yup, very well said, of course i am also making sure that if javascript is disabled or unavailable people can still surf my site thats my i am looking for ways to incorporate javascript with php
Reply With Quote
Reply

Tags
validation

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript Help Daniel JavaScript Forum 5 Jan 4th, 2007 22:00
JavaScript cbrams9 JavaScript Forum 1 Sep 20th, 2006 17:35
using xml in javascript shailu JavaScript Forum 0 Jul 25th, 2006 07:36
Can someone help me with this javascript Galaxyblue JavaScript Forum 2 Mar 11th, 2004 12:18
what does \\ mean in javascript jenjen1018 JavaScript Forum 5 Jan 6th, 2004 17:05


All times are GMT. The time now is 00:06.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43