Jump to content

Change text within a html table cell if submit button is clicked


mrherman

Recommended Posts

I have an html table that contains 1 row and 3 cells.  Each of the 3 cells contains a submit button.  Below the submit button in each cell are instructions for when to use the submit button.

 

Is it possible to change the instructional text within the cell after a user clicks on a submit buttons?

 

If so, how would I do that? (Looking for php/html/css only, since I don't know javascript.)

 

Thanks!

If you want to change text on button click dynamically (without reloading page) you'll have to use Javascript.

Otherwise, if you wish to implement this with PHP, here is how:

 

<html>
<body>
<form method="post">
<table>
<tr>
<?php
  for($i=1;$i<=3;$i++){
    echo '<td>';
    echo '<input type="submit" name="button'.$i.'" value="Submit '.$i.'">';
    echo $_POST["button".$i]?('Text here, button '.$i.' pressed')'Default text - button not pressed');
    echo '</td>';
  }
?>
</tr>
</table>
</form>
</body>
</html>

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.