Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

input[type=text] submit different value than displayed

I am developing an app using Rails and jQuery. I would like to submit an id integer value via an input form but still display a friendly text value to the user while he is filling out the form. The text input field is using jQuery autocomplete so once the user chooses an entry, an integer value will be put into the input field. Is there any way to display a different value from what is actually submitted?

like image 373
Pogopuschel Avatar asked Oct 11 '22 04:10

Pogopuschel


2 Answers

Alternatively, you can also keep a hidden input field, and use a "change" event to keep the hidden input field updated every time the user changes the original field.

like image 141
rags Avatar answered Oct 14 '22 04:10

rags


Try using the combobox functionality for the jQuery UI Autocomplete:

http://jqueryui.com/demos/autocomplete/#combobox

The value attribute of the options are what get sent along with the form, not the display text.

like image 36
IOrlandoni Avatar answered Oct 14 '22 03:10

IOrlandoni