Hi
I need to create n 'submit' buttons for n different files. I want to perform file processing based on which submit button is clicked. I wrote this very simple code and works also but once I pressed a button all other buttons stop functioning. If i click some other link on the page and come back then the buttons start functioning again. What is going on here?

<?php
for ($i in 1: 10)
{
?>

<FORM action="process.php" method="post" target="_blank">
<INPUT type="submit" name='filename' value==$filename[$i]>
</FORM>

<?php
}
?>

    The code you showed here does not diplay this behaviour, as it will load process.php an navigate away from the script...

      leatherback;10994513 wrote:

      The code you showed here does not diplay this behaviour, as it will load process.php an navigate away from the script...

      My actual code is similar to this and it is working perfectly.

      <?php
      $filenames = array("file1.txt", "file2.txt", "file3.txt");
      $namesToshow = array("file1", "file2", "file3");
      $numfiles = count($filenames);

      for ($i = 0; $i< $numfiles; $i++)
      {
      print($filenames[$i]);
      ?>

      <form method=GET action="viewResult.php" target="_blank" >
      <input type="hidden" name="filetoview" value="<?php $filenames[$i] ?>" >
      <input type="submit" style="height: 25px; width: 200px" value="<?php $namesToshow ?>" >
      </FORM>
      <br>

      <?php
      }
      ?>

      [/code]

      I think this error is language specific. I am not sure why it is happening, but I am facing this problem.

      When I click some other link other than these buttons and come back the buttons start functioning.

      Does it has something to do with refreshing the page? or something else.
      Thanks.

        <input type="submit" style="height: 25px; width: 200px" value="<?php $namesToshow ?>" >

        Did you mean to put the constant lowercase i here or did you perhaps mean to use the variable $i?

          Derokorian;10994525 wrote:

          <input type="submit" style="height: 25px; width: 200px" value="<?php $namesToshow ?>" >

          Did you mean to put the constant lowercase i here or did you perhaps mean to use the variable $i?



          This is $i.

            You also need to say what you want to do with $namesToShow[$i] - in this case, print it.

              Hi all
              thanks for reply. After spending almost two days on this I finally diagnosed the problem but still searching for answer.

              I am restating the problem below:

              I have testframe.php that loads testinpform.php into right frame containing code to create 3 buttons. when I load the testframe.php, It shows all the the buttons in the right frame and all the buttons work as desired for the first time. once a button is clicked, none of the buttons work work after. When I move to some other page using some other link and come back, then these buttons start working again.

              This beavior is shown by Chrome browser.

              In chrome itself, if I load testinpform.php, all the buttons work as desired.
              In firefox, the same code work pefectly fine with or without frame.

              So, Is this a problem of chrome or I need to add something in my code to make it work in all browsers.

              My code is as follows.

              testframe.php

              <?php 
              
              // This code creates two frames. The left frame is a textarea that you can write 
              // PHP code in and execute it. On the right frame you will see the result of the 
              // code that was executed. 
              
              /* -BEGIN PHP TESTER */ 
              
              function generateFrames() { 
              echo "<FRAMESET  COLS=\"360,*\">\n"; 
              echo "<FRAME noresize NAME=\"input\" SRC=\"otherfile.php?page=left\">\n"; 
              echo "<FRAME NAME=\"output\" SRC=\"testinpform.php?page=right\">\n"; 
              echo "</FRAMESET>"; 
              } 
              
              if($page=="left") { 
              echo "<BODY BGCOLOR=\"#FFFFFF\">"; 
              echo "<FONT FACE=\"Arial,Verdana,Helvetica\" COLOR=\"FF0000\" SIZE=\"3\">PHP Tester</FONT>"; 
              echo "<FORM METHOD=\"get\" ACTION=\"processForm.php?page=right\" TARGET=\"output\">\n"; 
              echo "<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\">\n"; 
              echo "<TR><TD><TEXTAREA NAME=\"input\" COLS=\"100\" ROWS=\"40\" 
              WRAP=\"virtual\">".$input."</TXTAREA></TD></TR>\n"; 
              echo "<TR><TD ALIGN=\"center\"><INPUT TYPE=\"submit\" 
              VALUE=\"Execute\"></TD></TR></TABLE></FORM>\n"; 
              echo "</BODY>"; 
              } 
              
              else if ($page=="right") { 
              echo "<BODY BGCOLOR=\"#FFFFFF\">"; 
              if(empty($input)) { 
              echo "Ready to parse..."; 
              } 
              else { 
              $input=stripSlashes($input); 
              eval($input); 
              } 
              echo "</BODY>"; 
              } 
              
              else { 
              generateFrames(); 
              
              } 
              
              /* END PHP TESTER */ 
              
              ?>
              

              testinpform.php

              <?php
              $filenames =  array("file1.txt", "file2.txt", "file3.txt");
              $namesToshow = array("file1", "file2", "file3");
              $numfiles = count($filenames); 
              
              for ($i = 0; $i< $numfiles; $i++)
              {
              echo"<form enctype=multipart/form-data method=GET action='viewResult.php' target='_blank' >";
              echo"<input type='hidden' name='filetoview' value= $filenames[$i] >";
              echo"<input type='submit' value= $namesToshow[$i] >";
              echo'</FORM>';
              }
              
              
              echo"<a href= abc.com>click here to go to next page and then come back using the back button>";
              ?>
              
              
                Write a Reply...