iwan_groznyj iwan_groznyj - 2 months ago 6
HTML Question

Submit buttons: button text different from value

I am writing a search form in PHP.
I want the user to be able to add search fields using following submit button:

<input type="submit" name="fields" value="<?php echo $fields+1 ?>" />


Now the button shows the value of
$fields + 1
.
Actually what I want is the button to show something else (like add new field).
Just adding text between the
<input>...</input>
tags does not help.
The text just appears right of the button.

How do I change the text on the button and still pass the value of
$fields + 1
to GET/POST?

Answer

You can use an hidden input to store the value count, it will be available after GET/POST:

<input type="submit" name="fields" value="add new field" />
<input type="hidden" name="fieldsCount" value="<?php echo $fields+1 ?>" />
Comments