Jamus
Jamus

Reputation: 865

HTML Submit Button, different value to post data

I need the button text displayed to be different from the sent form value.

Is there a way to achieve this using CSS|HTML|PHP? Here's my pseudo.

<form  method='post' action='index.php'>
  <input type="submit" value="name1" name="remove">Remove 1</input>
  <input type="submit" value="name2" name="remove">Remove 2</input>
  <input type="submit" value="name3" name="remove">Remove 3</input>
</form>

<?php
  #Pressing Remove 1 will print "name1", Remove 2 will print "name2", etc.
  if(isset($_POST['remove']))
  {
      $_gone = $_POST['remove'];
      print $_gone
  }
?>

Upvotes: 0

Views: 2061

Answers (1)

Quentin
Quentin

Reputation: 944076

Use a button element (which can have child nodes), not an input element (which cannot).

<button type="submit" value="name1" name="remove">Remove 1</button>

Note that old IE has limitations here.

Upvotes: 2

Related Questions