View unanswered posts | View active topics It is currently Wed Aug 17, 2022 3:19 pm



Reply to topic  [ 2 posts ] 
 Foreach 
Author Message
Junior Member

Joined: Sat May 15, 2004 6:03 am
Posts: 1
Post 
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body>
Can anyone help me with this using php?<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" u-file="fpweb:///_private/form_results.csv" s-format="TEXT/CSV" s-label-fields="TRUE" -->


<input type="checkbox" name="C1" value="ON" checked>Option1</p>




<input type="text" name="T1" size="20" value="123" maxlength="1" readonly></p>



<input type="text" name="T2" size="20" value="124" readonly></p>


<input type="checkbox" name="C2" value="ON" checked>Option2</p>


<input type="text" name="T3" size="20" value="453" readonly></p>


<input type="checkbox" name="C10" value="ON">Option3</p>


<input type="text" name="T4" size="20"></p>


<input type="text" name="T6" size="20"></p>


<input type="button" value="Button" name="B1"></p>
</form>


Output should b like this..</p>


You selected:</p>



Option1</p>



123</p>



124</p>



Option2</p>



453</p>

</body>

</html>


Sat May 15, 2004 6:15 am
Report this post
Profile
Junior Member

Joined: Thu Apr 29, 2004 4:49 pm
Posts: 5
Post 
Code:
<html>
<head>
</head>

  <form method="POST" action="<?php echo $PHPSELF; ?>">
   <p>
    <input type="checkbox" name="C1" value="ON" checked>Option1</p>
   <p>
    <input type="text" name="T1_1" size="20" value="123" maxlength="1" readonly></p>
   <p>
    <input type="text" name="T1_2" size="20" value="124" readonly></p>
   <p>
    <input type="checkbox" name="C2" value="ON" checked>Option2</p>
   <p>
    <input type="text" name="T2_1" size="20" value="453" readonly></p>
   <p>
    <input type="checkbox" name="C3" value="ON">Option3</p>
   <p>
    <input type="text" name="T3_1" size="20"></p>
   <p>
    <input type="text" name="T3_2" size="20"></p>
   <p>
    <input type="submit" value="Button" name="B1"></p>
  </form>

<?php
  if (isset($_POST))
  {
   /*
   echo "<p>You selected:</p>";
   if (isset($_POST['C1']))
   {
    echo "<p>Option1</p>"
     .$_POST['T1']."<br>"
     .$_POST['T2']."<br>";
   }
   
   if (isset($_POST['C2']))
   {
    echo "<p>Option2</p>"
     .$_POST['T3']."<br>";
   }
   
   if (isset($_POST['C3']))
   {
    echo "<p>Option3</p>"
     .$_POST['T4']."<br>"
     .$_POST['T5']."<br>";
   }
   echo "<hr>";
   //That works (with old controls), but is rather static; the following would be dynamic if you continue to name the controls the same...(T1, T2, TX), (C1, C2, CX), etc
   for ($i=0;$i<count($_POST);$i++)
   {
    if (isset($_POST["C".$i]))
    {
     echo "<p>Option$i</p>"
      .$_POST["T".$i]."<br>";
    }
   } */
   //This only halfway works, so....
   
   //If you named the controls like T1.1, you can group any number of controls to a single check box
   //Number the checkboxes like C1, C2, CX, and textboxes like T1.1, T1.2, T1.3 [all w/C1], T2.1 [C2], TX.X [CX, any number])
   for ($i=0;$i<count($_POST);$i++)
   {
    if (isset($_POST["C".$i]))
    {
     echo "<p>Option$i is ".$_POST["C".$i]."</p>";
     for ($j=0;$j<count($_POST)-$i;$j++) //not extremely efficient, but I'm not going to take the time to speed it up (use explode to separate out and speed up)
     {
      if (isset($_POST["T".$i."_".$j]))
      {
       echo $_POST["T".$i."_".$j]."<br>";
      }
     }
    }
   }
  }
?>

</body>

</html>




Sat May 15, 2004 8:01 am
Report this post
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.