SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
-
Jul 27, 2007, 07:18 #1
a complex form with checkboxes and ajax...
I need to build a form with various fields that are checkboxes and each of which if checked reveal other text fields for example. How can ii do that? do i have to use ajax? If so is there a way to make an ajax request when a particular checkbox is checked to add other related fields on the fly?
-
Jul 27, 2007, 08:07 #2
- Join Date
- Aug 2005
- Posts
- 986
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You can use Ajax, but you probably don't have to. Your application will be snappier if you don't use Ajax. The Prototype library is bundled with Rails [1]. You can put the hidden form fields in hidden divs and make them appear with Element.show if the user clicks a checkbox.
RJS is a very interesting technology for Ajax applications [2], use it if you have to get data from your database to determine which fields should appear. This will be slower because new data has to be downloaded from the server.
[1] http://www.prototypejs.org/
[2] http://www.rubyinside.com/16-rjs-res...rammers-5.html
-
Jul 27, 2007, 12:19 #3
-
Jul 27, 2007, 13:41 #4
- Join Date
- Aug 2005
- Posts
- 986
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Code in the middle of html is not a big problem since you don't read the HTML, you read the Ruby (and it's nicely abstracted in Ruby).
You can keep the site accessible by providing a non-ajax interface to your site if the browser has js turned off.
-
Jul 28, 2007, 04:35 #5
Bookmarks