PHP and Javascript working together?

Reply

Join Date: Jan 2007
Posts: 19
Reputation: mbacon is an unknown quantity at this point 
Solved Threads: 0
mbacon mbacon is offline Offline
Newbie Poster

PHP and Javascript working together?

 
0
  #1
Jan 24th, 2007
Hello everybody,

I am wanting to use a javascript confirm popup (OK returns TRUE/Cancel returns FALSE) to determine whether I need to run part of my PHP code.

I could only think of one way to try, and this is it:

  1. echo "<script type=\"javascript\">
  2. var popbox = confirm(\"Are you sure you want to delete " . $x . " entries?\");
  3. if(popbox){";
  4.  
  5. php_code();
  6.  
  7. echo "}
  8. </script>";
But... since Javascript is client-side I know this might not be possible, so my question is, CAN I do this? And how?
Last edited by mbacon; Jan 24th, 2007 at 4:03 pm. Reason: Fixing broken php code
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: PHP and Javascript working together?

 
0
  #2
Jan 24th, 2007
It's called Ajax.
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 11
Reputation: theonlydrayk is an unknown quantity at this point 
Solved Threads: 0
theonlydrayk's Avatar
theonlydrayk theonlydrayk is offline Offline
Newbie Poster

Re: PHP and Javascript working together?

 
0
  #3
Jan 29th, 2007
you can use ajax or redirect the page from javascript

document.location.href = "http://domain.tld/file.php";
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC