Jenny
Jenny

Reputation: 1727

How to display input value as something else and still get the value?

I get pagination number from user input value like this:

$html .= "<input type='submit' name='next' value='$next_page_number' />";

I want to display this input value text as an arrow '→'.
How can I do this and still get the input value from $_POST?

Upvotes: 1

Views: 228

Answers (2)

RickN
RickN

Reputation: 13500

If you don't care about IE7 or lower, you can use:

<button type=\"submit\" name=\"next\" value=\"$next_page_number\"> → </button>

IE7 will send the button's innerHTML, that is, "" and not the value attribute's content.

Upvotes: 1

Michael Berkowski
Michael Berkowski

Reputation: 270697

Use a hidden input to store the actual value, having the name you currently assigned to your submit button.

<input type='hidden' name='next' value='$next_page_number' />
<input type='submit' name='submit' value='Your arrow thing' />

From the $_POST point of view, it does not know or care what kind of input the value originated in. It only knows what the input is named and the value it holds.

Upvotes: 2

Related Questions