One form will always post the same set of POST variables (sometimes a partial set, as 
when a checkbox is not checked, the variable is not passed)

So the best way is to add hidden fields to your form, and manipulate then in 
javascript, like in this example (several submit buttons, corresponding to different 
actions: "save under current name", "save under other name", etc.)

 <INPUT type="hidden" name="selector" value="">
<INPUT type="submit" name="submit" value="Save changes" onClick="javascript:save()">
<SCRIPT language="JavaScript">
  function save() {
   document.update_form.selector.value = "update" ;
   document.update_form.selector.submit() ;
  }
  function save_as() {
   document.update_form.selector.value = "save_as" ;
   document.update_form.selector.submit() ;  
  }
...

And your script at the end of the action="" will take different actions depending on 
the value of $_POST['selector']

HTH

Ignatius Reilly


--------------------------------------------------------------------------------

  ----- Original Message ----- 
  From: Kit Kerbel 
  To: [EMAIL PROTECTED] 
  Sent: Wednesday, August 21, 2002 4:40 PM
  Subject: [PHP-WIN] Checkbox problem


  I have a page that lists entries made by users in the database.  There are 
  three types of entries.  Each type of entry is stored in their own table.  
  My problem is this:  I want people to be able to click a checkbox next to 
  any of the entries and press a delete button and delete those entries.  The 
  only hang up is that the delete button works as a submit button and sends 
  the checkbox arrays as post variables to the next page and I'm trying to 
  figure out a way to send another post variable when you click delete.  
  something like my_listings?delete=true.
  not sure how, or if you can even do this with a submit button.  I also have 
  three other buttons on this page that do different things when pressed to 
  the boxes checked.  I tried using
  onclick="<?$_SESSION["delete"]="true";?>" in the delete(submit) button but 
  for some reason, this session variable is also set when I click the other 
  buttons as well, I guess because they are submit buttons too?   If you can 
  make sense of any of this, maybe you can help.

  Thanx in advance,
  Kit


  //this is what I do if the variable is set
  // **Marking Listings as Deleted
  if($_SESSION["delete"]=="true")
  {
  if(isset($_REQUEST["horse"]))
  {
  foreach($_REQUEST["horse"] as $value)
  {
  odbc_exec($connection, "UPDATE tblHorse SET dDeleted = 1 where dHorseID = 
  '".$value."'");
  }
  }
  if(isset($_REQUEST["trailer"]))
  {
  foreach($_REQUEST["trailer"] as $value)
  {
  odbc_exec($connection, "UPDATE tblTrailer SET dDeleted = 1 where 
  dTrailerID = '".$value."'");
  }
  }
  if(isset($_REQUEST["tack"]))
  {
  foreach($_REQUEST["tack"] as $value)
  {
  odbc_exec($connection, "UPDATE tblTack SET dDeleted = 1 where dTackID = 
  '".$value."'");
  }
  }

  }
  unset($_SESSION["method"]);


  //This is how i'm trying to set the variable
  <input type="image" src="images/button_activate.gif" width="114" height="19" 
  border="0" >
  <input type="image" src="images/button_sold.gif" width="114" height="19" 
  border="0" >
  <input type="image" src="images/button_renew.gif" width="114" height="19" 
  border="0" >
  <input type="image" src="images/button_delete.gif" width="114" height="19" 
  border="0" onclick="<?$_SESSION["delete"]="true";?>"></td>


  _________________________________________________________________
  Chat with friends online, try MSN Messenger: http://messenger.msn.com


  -- 
  PHP Windows Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php


Reply via email to