I have a form that looks something like this:
<form name="theForm">
<input name="Name" type="text" placeholder="Name" />
<select name="Options">
<option value=1>Option 1</option>
<option value=2>Option 2</option>
<option value=3>Other</option>
</select>
<button type="submit">Submit</button>
</form>
Behind the scenes, I have some javascript which, if the user is to select the third option (other), a text input is created where the user can type an input that does not appear in the list.
I've looked into posts like this and this, where the accepted answer changes the value of an existing input in the form before submission, but these do not suit my situation as I cannot simply change the value of the <select>
to a string.
So, I would like to ask if it is possible to alter the form data upon submission, so that if the third option is selected, the form submits the contents of the custom text box rather than the value 3
.
Thank you.