# Problema

**URL:** <https://www.ruby-forum.com/t/problema/130088>\
**Category:** IT\
**Created:** [February 25, 2008, 10:04am UTC](https://www.ruby-forum.com/t/problema/130088 "2008-02-25T10:04:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefanof](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aeb1de/32.png) [@stefanof](https://www.ruby-forum.com/u/stefanof)\
**Post date:** [February 25, 2008, 10:04am UTC](https://www.ruby-forum.com/t/problema/130088/1 "2008-02-25T10:04:40Z")

</div>

Buon giorno a tutti,  
ho due problemini ai quali non trovo soluzione.  
Supponiamo di avere la tabella “cars” al suo interno i campi “marca” e  
“tipo”.  
All’interno della form ho i campi marca e tipo (elenco a cascata): come  
faccio a settare automaticamente il valore marca dopo aver selezionato  
il “tipo”?  
per chiarezza: marca=Fiat e tipo=Brava.  
Se seleziono sull’elenco Brava, vorrei che automaticamente venisse  
settato il valore Fiat su “marca”.  
E’ ovvio che “Brava” esiterÃ solo per Fiat e nessun altro concorrente.

Secondo problemino.  
Supponiamo di avere all’interno della form tre campi chiamati “test1”,  
“test2” e “doppio”: come faccio a settare il valore di “doppio” a M se e  
solo se entrambi i campi “test1” e “test2” hanno un valore al loro  
interno, altrimento settarlo a S?

Spero di non aver creato troppa confusione.

Grazie

Stefano

---

<div class="post-metadata">

**Author:** ![stefanof](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aeb1de/32.png) [@stefanof](https://www.ruby-forum.com/u/stefanof)\
**Post date:** [February 25, 2008, 10:11am UTC](https://www.ruby-forum.com/t/problema/130088/2 "2008-02-25T10:11:25Z")

</div>

Puoi farlo in javascript senza passare dal server.  
Oppure direttamente in rails utilizzando la “observe\_field”:

[http://wiki.rubyonrails.org/rails/pages/How+to+make+a+real-time+search+box+with+the+Ajax+helpers](http://wiki.rubyonrails.org/rails/pages/How+to+make+a+real-time+search+box+with+the+Ajax+helpers)

ma su web ci sono tanti esempi.  
(vale per entrambi i problemini)
