Thursday, 15 August 2013

Appending text to input field on submit

Appending text to input field on submit

I have a form which looks like this:
<form>
<input type="text" value="" name="order[]" title="Salmon" />
<input type="text" value="" name="order[]" title="Trout" />
<input type="text" value="" name="order[]" title="Halibut" />
<input type="text" value="" name="order[]" title="Crab" />
<button type="submit">Submit</button>
</form>
Users will be inputting a number for the value. When they submit the form
I want to append the title of each input to the submission. So if the user
input "5" for the first input field, it would submit the value as "Salmon
- 5".
How could I achieve this with jQuery?

No comments:

Post a Comment