# Passing two id values through :with?

**URL:** <https://www.ruby-forum.com/t/passing-two-id-values-through-with/187047>\
**Category:** Rails\
**Created:** [April 16, 2010, 6:58am UTC](https://www.ruby-forum.com/t/passing-two-id-values-through-with/187047 "2010-04-16T06:58:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![veena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/51bf81/32.png) [@veena](https://www.ruby-forum.com/u/veena)\
**Post date:** [April 16, 2010, 6:58am UTC](https://www.ruby-forum.com/t/passing-two-id-values-through-with/187047/1 "2010-04-16T06:58:49Z")

</div>

Hai frnds,

```
I hav two select boxes.1st selectbox for selecting the "state" and

```

the 2nd selectbox will be populated with the “districts” based on the  
1st select box value.I want to show some details according to the  
district selected.

I am able to do these things.But i want to get both the id of 1st and  
2nd select box in the action “show\_readings\_for\_station”.Can i pass two  
ids with periodically\_call\_remote?

my code  
…  
\<%= periodically\_call\_remote(:url =\> { :action=\>  
“show\_readings\_for\_station” }, :frequency =\> 5,  
:with=\>"‘district\_id=’+document.getElementById(’\_district\_id’).value")%\>

“\_district\_id” is the id of 2nd select box. “\_state\_id” is the id of 1st  
select box.

Thanks,  
Veena

---

<div class="post-metadata">

**Author:** ![veena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/51bf81/32.png) [@veena](https://www.ruby-forum.com/u/veena)\
**Post date:** [April 16, 2010, 7:35am UTC](https://www.ruby-forum.com/t/passing-two-id-values-through-with/187047/2 "2010-04-16T07:35:29Z")

</div>

yes but different parameters name like one is district\_id and state\_id

---

<div class="post-metadata">

**Author:** ![veena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/51bf81/32.png) [@veena](https://www.ruby-forum.com/u/veena)\
**Post date:** [April 16, 2010, 8:47am UTC](https://www.ruby-forum.com/t/passing-two-id-values-through-with/187047/3 "2010-04-16T08:47:31Z")

</div>

Hi,

If you need to pass two values using periodically call remote,  
trying :with option is a good idea. Yes, we can pass more than one  
values  
with it.

Have a look at this, and try to follow the same -  
, :with =\> “‘tag\_last\_id=’+#{last\_activity.to\_i}+’&tag\_name=’+’#{tag}’”

THIS ONE IF the values of \_district\_id and \_state\_id are INTEGER  
“‘district\_id=’+$(’\_district\_id’).value+’&state\_id=’+$(’\_state\_id’).value”

THIS ONE IF the values of \_district\_id and \_state\_id are STRING  
“‘district\_id=’+’$(’\_district\_id’).value’+’&state\_id=’+’$(’\_state\_id’).value’”

And if that doesn’t work it would be coz $(‘element\_id’).value DIDN’T  
WORK.  
so just replace it with document.getElementById(‘element\_id’).value and  
it  
should be working then.

Good luck,  
Nitin.

---

<div class="post-metadata">

**Author:** ![veena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/51bf81/32.png) [@veena](https://www.ruby-forum.com/u/veena)\
**Post date:** [April 16, 2010, 9:13am UTC](https://www.ruby-forum.com/t/passing-two-id-values-through-with/187047/4 "2010-04-16T09:13:58Z")

</div>

Thank you Nitin…Thank you Bala…  
I got it worked…  
Thank you sooooo much. This was a new learning for me…

Thanks,  
Veena
