how can i make a window close itself after running the php code

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved

Join Date: Apr 2009
Posts: 281
Reputation: SKANK!!!!! is an unknown quantity at this point 
Solved Threads: 2
SKANK!!!!! SKANK!!!!! is offline Offline
Posting Whiz in Training
 
0
  #11
19 Days Ago
Originally Posted by jomanlk View Post
You'd have this kind of setup

First the Index page
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. //fake display structure
  2. <ul>
  3. <li>Item 1 - <a onclick="return confirm('Are you sure?')" href="delete.php?id=1">Delete</a></li>
  4. <li>Item 2 - <a onclick="return confirm('Are you sure?')" href="delete.php?id=2">Delete</a></li>
  5. <li>Item 3 - <a onclick="return confirm('Are you sure?')" href="delete.php?id=3">Delete</a></li>
  6. <li>Item 4 - <a onclick="return confirm('Are you sure?')" href="delete.php?id=4">Delete</a></li>
  7. </ul>

Now the delete page
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <?php
  2. $id = isset($_GET['id']) ? intval($id) : 0;
  3.  
  4. if ($id) { //just some validations
  5. //do delete commands
  6. header("Location: index.php"); //It's important that you haven't output anything upto this point
  7. }
  8. ?>

This way there are no new windows or popups.

If you want users to be able to delete multiple messages at once, you'd have to modify the code so that users can select which messages are to be deleted. You can use an array of checkboxes for this and modify the delete code to work with an array. But then you'd have to use a FORM element to submit. That's another topic, some info can be found here
im afraid header wont work here. but maybe ill try it. oh just tried it LOL im pretty sure im looking for a javascript redirect but im just confused how am i supposed to make it so that liike the thing knows where it got deleted from cause im keeping the inbox the way it is i just need to change the message page so it redirects i dont think header will work here myabe i use a variable on the other one so if deleting from inbox : do this and if not: do the redirecting i assume.
i just need to remember than darn redirect code... with js. dangit
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 99
Reputation: jomanlk is an unknown quantity at this point 
Solved Threads: 18
jomanlk jomanlk is offline Offline
Junior Poster in Training
 
0
  #12
19 Days Ago
The header used there is the PHP header command, It will work. If you need to know where you came from you can pass a variable or look at th PHP referrer. Javascript won't help you there I'm afraid.

Anyway, these were just some tips, you don't need to switch to it if it messes up your existing code. As long as it gets the job done
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 43
Reputation: manishmannan is an unknown quantity at this point 
Solved Threads: 2
manishmannan manishmannan is offline Offline
Light Poster
 
0
  #13
19 Days Ago
even you can try this code in any filter like in if else
echo'<script=javascript>window.close();</script>';
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 281
Reputation: SKANK!!!!! is an unknown quantity at this point 
Solved Threads: 2
SKANK!!!!! SKANK!!!!! is offline Offline
Posting Whiz in Training
 
0
  #14
19 Days Ago
ok no thats alreayd been stated before. but LOL the header actually did work... thanks im closing this cause u guys all helped a lot thanks again!
Reply With Quote Quick reply to this message  
Reply


This thread has been marked solved.
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