[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Button in first row of html table does not work

Posted on 2014-04-11
2
Medium Priority
?
1,159 Views
Last Modified: 2014-04-17
Hi all.

I have a php page (see below). Each row of data has a button, if the status is Open then the button is showed otherwise the button is not shown. When the button is clicked it goes to another file (ProcessToDoAction.php). Something weird is happening, the button on the first row of data does not work, meaning it does not go to the file ProcessToDoAction.php but rather it goes to the form's action (LookupResultsConvertJobType.php). And again this only happens on the first row of data, if I click the button on the second row it goes to the correct file (ProcessToDoAction.php).

Any idea why this is happening?

Thank you in advance.

  <head>
  <title>MyPage</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <link rel="stylesheet" href="style.css" type="text/css" />
  <link href="iphone-icon1.png" rel="apple-touch-icon">
  </head>
<body>
      				
<div class="wrapper">
    <div id="logo"></div>
    <form class="form4" action="LookupResultsConvertJobType.php" method="post">
<div class="formtitle4">Lookup Form</div>
  </head>
<body>
  <div class="input3">
                       <div class="inputtext">Job Type:</div>
               <div class="inputcontent" >
                    <?php  foreach($data as $row){ echo '<input type="text" name="jobtype" id="jobtype" value="' . html_escape($row['jobtypedescription']) . '">'; } ?>           
               </div>
               <?php if ($row['Type'] == 1 AND	$row['Status'] <> 'Completed') {
               echo '<input class="button5"  type="submit" value="Convert to D"/><p></p>'; }
               		 
               		 elseif ($row['Type'] == 2 AND	$row['Status'] <> 'Completed') {  // Job type is 2
	               		 echo '<input class="button5"  type="submit" value="Convert Back To S"/><p></p>';
               		 }  ?>              
           
          </div>
           
		  <div class="input3">
            
                <table cellpadding="0" cellspacing="0"  class="db-table" align = "center">
                <tr>
                <th>To Do</th>
                <th>Status</th>
                <th>Date</th>
                <th>Action</th>
                </tr>
                               
                <?php  foreach($data1 as $row){ 
                    echo '<tr>';
                    echo '<td>' . html_escape($row['ToDo']) . '</td>';
                    echo '<td>' . html_escape($row['Status']) . '</td>';
                    echo '<td>' . html_escape($row['ToDoStatusDate']) . '</td>';
                     if ($row['Status'] == 'Open') 
					{
						echo "<td>
						<form action='ProcessToDoAction.php' method='post'>        					
						<input type='text' id='DataEntryID' name='DataEntryID' value='" . html_escape($row['DataEntryID']) . "'/>
						<input type='text' id='todoid' name='todoid' value='" . html_escape($row['ToDoID']) . "'/>
						<input class='button8'  type='submit'  value='Complete'/>
						</form>				
						</td>";
					}

				   else
				   {
					   echo "<td>                 
					   	<input type='hidden' name='todoid' value='" . html_escape($row['ToDoID']) . "'/>      
					   	</td>";   
				  }
                    echo '</tr>';
                   
                } ?>                 
               </table>

			<div class="buttons" align = center>

				<input class="button1"  type="submit" formaction="BacktoLookup.php" value="Search" /> 
				<input class="button1"  type="submit" formaction="Menu.php" value="Menu" /> 
				<input class="button1"  type="submit" formaction="Shortage.php" formmethod="post" value="Shortage" /> 		
			</div>   
</form>
</div>
</body>
</html>

Open in new window

0
Comment
Question by:Sim1980
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 43

Assisted Solution

by:Rob
Rob earned 1000 total points
ID: 39995986
This is to do with nested forms, forms within forms.  You can't do that, which is why you're getting it working once and not after that because the browser has submitted that form but even this could give you unexpected results across browsers (and versions thereof).  

You'll need to rethink your design.

Having said that, I don't think it's going to be too hard but I would need to know more info on both ProcessToDoAction and LookupResultsConvertJobType but I suspect you may be able to call the ProcessToDoAction using ajax (and hence removing those form tags in the rows).  Then you can submit the main form LookupResultsConvertJobType once all rows have been "modified"
0
 
LVL 34

Accepted Solution

by:
Slick812 earned 1000 total points
ID: 39996403
Hello Sim1980, You may have better HTML if you take OUT all of the -
<form action='ProcessToDoAction.php' method='post'>

from the -
<form class="form4" action="LookupResultsConvertJobType.php" method="post">

so the browser can work with a single form at a time, ,

also your HTML is very messed up you have TWO -
</head>
<body>

which can get the browser to be inconsistent.

Also you have this DIV - <div class="input3">  start INSIDE a <form> , BUT it ends with </div>  OUTSIDE that form as -
</form>
</div>

making the browser display inconsistent, , you might try something like -
  <head>
  <title>MyPage</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <link rel="stylesheet" href="style.css" type="text/css" />
  <link href="iphone-icon1.png" rel="apple-touch-icon">
  </head>
<body>
      				
<div class="wrapper">
    <div id="logo"></div>
    <form class="form4" action="LookupResultsConvertJobType.php" method="post">
<div class="formtitle4">Lookup Form</div>
  <div class="input3">
   <div class="inputtext">Job Type:</div>
    <div class="inputcontent" >
<?php  foreach($data as $row){ echo '<input type="text" name="jobtype" id="jobtype" value="' . html_escape($row['jobtypedescription']) . '">'; } ?>           
    </div>
<?php if ($row['Type'] == 1 AND	$row['Status'] <> 'Completed') {
  echo '<input class="button5"  type="submit" value="Convert to D"/><p></p>'; }
  elseif ($row['Type'] == 2 AND	$row['Status'] <> 'Completed') {  // Job type is 2
    echo '<input class="button5"  type="submit" value="Convert Back To S"/><p></p>';
    }  ?>              
  </div>
   
  <div class="buttons" align = center>
  <input class="button1"  type="submit" formaction="BacktoLookup.php" value="Search" /> 
  <input class="button1"  type="submit" formaction="Menu.php" value="Menu" /> 
  <input class="button1"  type="submit" formaction="Shortage.php" formmethod="post" value="Shortage" /> 		
  </div>   
</form>


<div class="input3">
     <table cellpadding="0" cellspacing="0"  class="db-table" align = "center">
<tr>
<th>To Do</th><th>Status</th><th>Date</th><th>Action</th>
</tr>
<?php  foreach($data1 as $row){ 
  echo '<tr>';
  echo '<td>' . html_escape($row['ToDo']) . '</td>';
  echo '<td>' . html_escape($row['Status']) . '</td>';
  echo '<td>' . html_escape($row['ToDoStatusDate']) . '</td>';
  if ($row['Status'] == 'Open') {
    echo "<td>
    <form action='ProcessToDoAction.php' method='post'>        					
    <input type='text' id='DataEntryID' name='DataEntryID' value='" . html_escape($row['DataEntryID']) . "'/>
    <input type='text' id='todoid' name='todoid' value='" . html_escape($row['ToDoID']) . "'/>
    <input class='button8'  type='submit'  value='Complete'/>
    </form>				
    </td>";
  } else {
  echo "<td>                 
  <input type='hidden' name='todoid' value='" . html_escape($row['ToDoID']) . "'/>      
  </td>";   
  }
  echo '</tr>';
} ?>                 
    </table>
</div>

Open in new window

notice that I removed ALL of the <div class="input3"> OUTSIDE of the -
<form class="form4" action="LookupResultsConvertJobType.php" method="post">
    <form> code
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question