0

Technologies : Asp.Net MVC3 / Razor

I am generating a dynamic form with a list of questions of types listed bellow :

  • Text : Question with a textbox
  • Multiplechoice : Question with a list of checkboxes
  • Singlechoice : Question with a list of radiobuttons

All this works perfectly, when I post the form I use a modelbinder to match the model and the selected answers

BUT :

Now I want to customize the Multiple and Single choice :

  • Multiplechoice : Question with a list of checkboxes with or without an additional Textbox associated to a checkbox
  • Singlechoice : Question with a list of radiobuttons with or without an additional Textbox associated to a radiobutton

When I get the posted collection in my modelbinder, I dont find a way to associate a checkbox/radio and the corresponding Textbox answer

How can I handle this ?

1 Answer 1

1

I guess you are trying to achieve letting the user select "Other" and fill in their own value if none of the options match.

You can do this with javascript, add your radiobutton with value Other or whatever, then assign an onBlur handler to your textbox that sets the value of your Other radiobutton to the value of the textbox. See this example:

http://jsfiddle.net/rrVps/1/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.