Categories
HTML5 Uncategorized

HTML Forms and Submit Button Changing Name

This article explores HTML webforms and specifically the submit button in terms of changing the name, id and value. We explore Submit Button Changing Name Examples.

Example 1: Simple form tags and a frugal submit input

<form>

<input type=”submit” />

</form>

Result 1: Submit label is ‘Submit’, Default action is to do a Get.

Example 2: Simple form with post method and frugal submit

<form method=’post’>
<input type=’submit’>
</form>

Result 2: Submit label is ‘Submit’, Does a Post with no form data.

Example 3: Simple Form with Post and submit with id

<form method=’post’>
<input type=’submit’ id=’test’>
</form>

Result 3:  Submit is still called submit, Does a Post with no form data.

Example 4: Simple Form with Post and Submit with a Name

<form method=’post’>
<input type=’submit’ name=’test’>
</form>

Result 4:  Submit is still Submit, Does Post that contains form data: $_POST[‘test’] = ‘Submit’;

Example 5: Simple Form with Post Submit with a Name and a Value

<form method=’post’>
<input type=’submit’ name=’test’ value=’foo’>
</form>

Result 5: Submit is now labelled ‘foo’, does a post of form data: $_POST[‘test’] = ‘foo’;

Example 6: Simple Form with Post Submit with a Value Attribute

<form method=’post’>
<input type=’submit’ value=’foo’>
</form>

Result 6: Submit labelled foo, but no form data.