# Tricky issue - AJAX + form text fields + sortable\_list

**URL:** <https://www.ruby-forum.com/t/tricky-issue-ajax-form-text-fields-sortable-list/158256>\
**Category:** Rails\
**Created:** [January 21, 2009, 4:09am UTC](https://www.ruby-forum.com/t/tricky-issue-ajax-form-text-fields-sortable-list/158256 "2009-01-21T04:09:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![taylorstrait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@taylorstrait](https://www.ruby-forum.com/u/taylorstrait)\
**Post date:** [January 21, 2009, 4:09am UTC](https://www.ruby-forum.com/t/tricky-issue-ajax-form-text-fields-sortable-list/158256/1 "2009-01-21T04:09:10Z")

</div>

I have a custom form builder that has a question type of “rank order.”  
That is where you rank the choices in order from 1-5, or whatever. So I  
have the answer choices set up as a sortable list that has a text field  
with the order position. Using AJAX, I can change the order of these  
answers AND update the text fields with the proper numerical rank.

The problem is that when the form is POST submitted, it does not use the  
AJAX-updated values in the text fields but the original values from the  
page load DESPITE the text fields being different. If I manually change  
the field by typing, it POSTs correctly. How can I force the form to  
grab the “fresh” values from the text fields on submittal?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![taylorstrait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@taylorstrait](https://www.ruby-forum.com/u/taylorstrait)\
**Post date:** [January 22, 2009, 2:08am UTC](https://www.ruby-forum.com/t/tricky-issue-ajax-form-text-fields-sortable-list/158256/2 "2009-01-22T02:08:37Z")

</div>

Taylor S. wrote:

> grab the “fresh” values from the text fields on submittal?  
> What browser are you using, what code are you using to set the  
> field contents, and what version of Prototype are you using?

–  
Rails Wheels - Find Plugins, List & Sell Plugins -  
[http://railswheels.com](http://railswheels.com)

---

<div class="post-metadata">

**Author:** ![taylorstrait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@taylorstrait](https://www.ruby-forum.com/u/taylorstrait)\
**Post date:** [January 22, 2009, 2:20am UTC](https://www.ruby-forum.com/t/tricky-issue-ajax-form-text-fields-sortable-list/158256/3 "2009-01-22T02:20:36Z")

</div>

Mark Reginald J. wrote:

> Taylor S. wrote:
> 
> > grab the “fresh” values from the text fields on submittal?  
> > What browser are you using, what code are you using to set the  
> > field contents, and what version of Prototype are you using?

I had tested this on FF3. I went back with Safari to test it and it was  
working. So I went back with FF3 and it is ALSO working. Perhaps the  
bugfix was a side effect of some code changes today. Thanks for  
responding!

As far as my methodology, I have Answers with variable “position.” On  
the ajax update, I build a new list of text\_fields with ‘value =  
@answer.position.’ This allows both drag and drop and manual sorting  
with no code changes. The sortable\_list java will silently fail on  
non-java browsers and the user can just fill in the text boxes as they  
wish.
