On Dec 13, 2011, at 1:11 AM, Reva wrote:

> hi
> i m new to rails and i m facinga problem with radio buttons. i need to
> create a portal with multiple choice question. i m using html here.
> once i submit the answer the page is getting refreshed and the
> selected radio button is also refreshed. and is show a page with no
> radio button selected.

The page is going through a submit/refresh cycle, and that does re-set the form 
elements to their default.

> 
> <form>
> <br>
> <input type="radio" name="radios1"
> onclick="this.parentNode.submit();"  value="<%=@abc.a%>"><%=@abc.a
> %><br>
> <input type="radio" name="radios1"
> onclick="this.parentNode.submit();" value="<%=@abc.b%>"><%=@abc.b%>
> <br>
> <input type="radio" name="radios1"
> onclick="this.parentNode.submit();" value="<%=@abc.c%>"><%=@abc.c%>
> <br>
> <input type="radio" name="radios1" onclick="this.parentNode.submit();"
> value="<%=@abc.d%>"><%=@abc.d%> <br>
> <br>
> <br>
> <br>
> <input type="submit">
> </form>
> 
> please do give me a solution  for this

You have two options -- either submit the form through Ajax, so the page 
doesn't get refreshed, or store the result of the form submission in the 
session or the database and use it to default the form to the chosen value when 
the visitor reloads the form.

Walter

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to