Jump to content

Frustrated with box code


OldManRiver

Recommended Posts

All,

 

I found a good example of code to toggle a couple of radio buttons at:

 

 

The example I chose, was the one shown for radio buttons, but I wanted to adapt it for checkboxes but could not get the right action.

 

Most important, from other examples, one should be able to add to the "onclick" action the following:

 

; document.myform.submit()

 

and be able to call the PHP processing.  I am showing an IFRAME as an inset on the page and trying to switch between which data table is shown from the DB, but which button is selected.  But somehow I can not get the PHP processing to work right.  It either does not get called or gets called with all the same values, so I can not process the variance.  I've put in the trap for my vars of:

 

    foreach ($_POST as $key => $val) {
       echo "K=> $key V=> $val <br>";
    }

 

Right now my code is:

 

<?php
//    session_start();
    foreach ($_POST as $key => $val) {
       echo "K=> $key V=> $val <br>";
    }
    if (!isset($chk0) && !isset($chk1)) {
       $acc_chk = 'checked';
       $typ_chk = '';
    }
    echo "0=> $chk0 1=> $chk1 <br>";
    switch ($acc_chk) {
       case "":
    echo "Found Accounts! <br>";
       $acc_chk = 'checked';
       $typ_chk = '';
       break;
       case "checked":
    echo "Found Types! <br>";
       $acc_chk = '';
       $typ_chk = 'checked';
       break;
    }
    echo "A=> $acc_chk T=> $typ_chk C=> $chk_box <br>";

//       <input name='chk' type=radio
//          onclick=Set_Checked('chk1');
//          document.accform.submit()>
//       	  Type
//       </input>
?>

<html>
<head>
<STYLE>
.button{
   width: 150px;                /* sets the size of the menu blocks */
   color: blue;
   font-family:verdana;
   font-weight:bold;
   font-size:12pt
}
</STYLE>
<script type="text/javascript">
   function Set_Checked(type) {
      document.getElementById("chk0").style.display = "none"
      document.getElementById("chk1").style.display = "none"
      document.getElementById(type).style.display = ""
      this.form.submit()
   }
</script>

<!--link rel="stylesheet" type="text/css" href="acc_style.css"-->
<title>Accounts Main</title>
</head>

<body>
<p>
<form method='POST' NAME='accform' ACTION="<?php $_SERVER['PHP_SELF']; ?>">
<table width=95% border=2 align=center>
   <tr>
   <td width=150 align=left rowspan=6 valign=top bgcolor=#aaaaaa>
       <?php include('acc_men_l.php'); echo $l_men; ?>
   </td>
   <td colspan=2 align=center>
       <font face=verdana size=3><b>Accounts Mains</b></font>
   </td>
   </tr>

   <tr>
   <td width=50% align=left>
       <input type="hidden" name="chk0" value="true">
       <input name='chk' type=radio checked
          onclick=Set_Checked('chk0')>
       	  Accounts
       </input>
   </td>

   <td width=50% align=right>
       <input type="hidden" name="chk1" value="false">
       <input name='chk' type=radio
          onclick=Set_Checked('chk1')>
       	  Type
       </input>
   </td>
   </tr>

   <tr>
   <td colspan=2>
       <IFRAME WIDTH=95% HEIGHT=350 id='acc' frameborder="0"
          src=acc_db_main.php?tbl_val='acc' style="">
       </IFRAME>
       <IFRAME WIDTH=95% HEIGHT=350 id='typ' frameborder="0"
          src=acc_db_main.php?tbl_val='typ' style="display:none">
       </IFRAME>
   </td>
   </tr>

   <tr>
   <td> </td>
   </tr>

   <tr>
   <td align=center colspan=2>
      <input type="hidden" name="action" value="submitted">
      <input type=submit name=sync value=Synchronize>
   </td>
   </tr>
</table>
</form>

</body>
</html>

 

and it is not calling the PHP processing.

 

What do I need to change?

 

Thanks!

 

OMR

Link to comment
https://forums.phpfreaks.com/topic/137785-frustrated-with-box-code/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.