Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Link in view based on parameter


  • Please log in to reply
2 replies to this topic

#1 wazon

wazon

    Passenger

  • Members
  • 5 posts

Posted 06 November 2013 - 01:58 PM

Hello everyone,

I'm trying to create a view (just a view, no model associated) in which a specific option appears based on another option you click. Let's see if I can explain it:

 

Imagine a page (it should be a form, I guess) with 3 parts (A, B, C). Every part is a group of options and you can only choose 1 option per group. In this scenario, how could I make part C depend on what I choose in part A? so I could choose between options C1 and C2 if I choose A1, but A2 will led me to C3 or C4.

 

I hope it's clear enough and someone knows the answer!! :D

 

Thank You,

Wazon



#2 Ohm

Ohm

    Guard

  • Members
  • 181 posts
  • LocationCopenhagen

Posted 06 November 2013 - 06:09 PM   Best Answer

This sound like a frontend type of thing. You could hide all of B and C and then after selecting A1 or A2 show the appropriate part of B and C with Javascript.


Blog: http://ohm.sh | Twitter: madsohm


#3 Adam

Adam

    Inspector

  • Administrators
  • 71 posts

Posted 07 November 2013 - 08:48 AM

Yep - sounds like a job for javascript. If you're new to it, take a look at jQuery (http://jquery.com/) - there's loads of tutorials around which should help you do what you're trying to achieve. 


Adam Cooke

from aTech Media - UK-based Ruby on Rails developers. 

 

Follow me on Twitter  •  Check out my code on GitHub  •  Take a look at my designs





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users