# How to assign a id dinamically to checkbox created dinamical

**URL:** <https://www.ruby-forum.com/t/how-to-assign-a-id-dinamically-to-checkbox-created-dinamical/117631>\
**Category:** Rails\
**Created:** [October 18, 2007, 8:11pm UTC](https://www.ruby-forum.com/t/how-to-assign-a-id-dinamically-to-checkbox-created-dinamical/117631 "2007-10-18T20:11:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vasure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/7ea924/32.png) [@vasure](https://www.ruby-forum.com/u/vasure)\
**Post date:** [October 18, 2007, 8:11pm UTC](https://www.ruby-forum.com/t/how-to-assign-a-id-dinamically-to-checkbox-created-dinamical/117631/1 "2007-10-18T20:11:42Z")

</div>

hi

---

<div class="post-metadata">

**Author:** ![vasure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/7ea924/32.png) [@vasure](https://www.ruby-forum.com/u/vasure)\
**Post date:** [October 18, 2007, 8:19pm UTC](https://www.ruby-forum.com/t/how-to-assign-a-id-dinamically-to-checkbox-created-dinamical/117631/2 "2007-10-18T20:19:02Z")

</div>

Vasu Re wrote:

> hi

it got sumbmitted before writing Q:),  
ok so iam using  
\<%= check\_box\_tag ( “id”,“word”,false, :onclick =\> remote\_function( ))%\>  
for sending remotecall but i want “id” and value ie “word” to be diff  
as i load

like iam looping through records as shown below

\<%for x in @xrecords%\>  
\<%= check\_box\_tag ( “\<%x.id%\>”,“word”,false, :onclick =\>  
remote\_function( ))%\>  
\<%end%\>  
but this is not taking \<%x.id%\> but throwing exception,please let me  
know if there is a way to do this ie assigning the id dinamically as i  
loop

---

<div class="post-metadata">

**Author:** ![vasure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/7ea924/32.png) [@vasure](https://www.ruby-forum.com/u/vasure)\
**Post date:** [October 19, 2007, 2:13pm UTC](https://www.ruby-forum.com/t/how-to-assign-a-id-dinamically-to-checkbox-created-dinamical/117631/3 "2007-10-19T14:13:05Z")

</div>

> \<%for x in @xrecords%\>  
> \<%= check\_box\_tag ( “\<%x.id%\>”,“word”,false, :onclick =\>  
> remote\_function( ))%\>  
> \<%end%\>  
> but this is not taking \<%x.id%\> but throwing exception,please let me  
> know if there is a way to do this ie assigning the id dinamically as i  
> loop

Hi Vasu,

You need to be putting x.id within curly brackets so that it reads:

\<%= check\_box\_tag ( “#{x.id}”,“word”,false, :onclick =\>

> remote\_function( ))%\>

That should stop the exception.

Kind Regards

Robin
