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

  • Home
  • SEARCH
  • 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 7739069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:25:43+00:00 2026-06-01T08:25:43+00:00

Good evening, I’d like to set up a form with a single field (name),

  • 0

Good evening,

I’d like to set up a form with a single field (name), where the user inputs their name, and then they select one of three buttons.

Each of these buttons should simultaneously set a particular attribute value, and submit the form.

A contrived example (“xxxx” is a button):

Name : _________
"Good" "Sad" "Tired"

This would save the user’s name, and then yes/no/maybe to the “users_feeling” attribute. I don’t want to have a radio box for the user feeling attribute and then a separate submit button.

Any help you could provide would be appreciated!!

  • 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-06-01T08:25:44+00:00Added an answer on June 1, 2026 at 8:25 am

    There are two ways how to do this in general.

    IMHO the better one is to simply add the attribute you want to set as a hidden field, and then write some javascript to set it to perhaps some data attribute on the button. Something like this:

    $('.my_form button').click ->
      $('#my_hidden_field').val ($ @).data 'attribute-name'
      $('.my_form')[0].submit()
    

    The other is that each submit button will pass its value as a parameter when you submit the form. You can detect this in your rails controller like any other value. So if you have this HTML:

    <input type=submit name=feeling value=Good />
    <input type=submit name=feeling value=Sad />
    <input type=submit name=feeling value=Tired />
    

    Then in your controller params[:feeling] should hold the value of the button clicked. Why I don’t particularly like this solution is that the value string is also what is displayed to the user which couples your controller with your view rather nastily. If in the future you’d like to localize your app this will likely bite you.

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

Sidebar

Related Questions

Good evening, I am developing a set of Java classes so that a container
Good Evening, I'm using Drupal 6, CCK Module, and the Link Field Type. All
Good evening, I have one table, with a timestamp column, then I have a
Good Evening, I'm building a website which will will look something like this: So
Good evening, I was wondering if I could do something like: while(true) { MyEnum
Good evening residents =) I'm drawing and then calling sleep in a cycle, but
good evening, how to set custom error OR prevent page damage when display_errors=0 AND
Good evening, In my app that I'm currently developing, I have a class that
Good evening all, I've been working on an MD5 tool in C# that takes
Good evening ladies and gentlemen! Searching for a cross-browser solution to embed commercial fonts

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.