Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3630224
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:14:35+00:00 2026-05-19T00:14:35+00:00

I have a form with a text_field in my app where I input the

  • 0

I have a form with a text_field in my app where I input the name of a book. The book already exists in my database. How can I submit the ID of the book in the form instead of the name?

I should mention that I don’t want to use a collection select here, because I want this to eventually be an auto-complete field.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T00:14:35+00:00Added an answer on May 19, 2026 at 12:14 am

    You should handle this logic with your autoselect.

    $('.book_search').live('keyup.autocomplete', function(){
      $(this).autocomplete({
        source : '/ajax_functions/book_search',
        select : function(event, ui){
          book_id = ui.item.id;
          label = ui.item.value;
    
          $(this).before(label); // replace with text
          $(this).before('<input name="books'+[book_id]" type="hidden" value="'+user_id+'">');
          $(this).remove();
          return false;
        }
      });
    });
    

    You’re autocomplete json:

    books = []
    Book.search(params[:term]).each do |b|
      books << { :label => b.name, :id => b.id }
    end
    
    render :json => books
    

    This will do what you want. You’ll still need to implement server logic to add new books that don’t yet exist.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form with two text_fields: <input type=text id=post_name name=post[name] /> <input type=text
I have a form where users can add input fields with jQuery. <input type="text"
I have a little php/mysql app I put together that takes an input form
I have an iPhone app with a normal form (text input fields). I would
I have n number of text fields named in the form Question...... How can
I have a page which displays a form that a logged-in user can use
In my web app, users can input text data. This data can be shown
so i have this code: <% form_tag(:action => 'find') do%> Product name: <%= text_field(cars_,
I have an express app that I want to use the connect-form module on
I have a form field in my Rails app with a placeholder. I'd like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.