Topic: AJAX Form Serialize problem

I'm currently programming a system that can order print jobs online, the user selects a Type of printing (flyers, cards... what ever). Then selects a product, then a format and a quantity this then each step of the way the form is updated with ajax, and when selecting a format etc the price is calculated.

Now my problem is that they can also select special options per order, like Numbering or Cutting. these options cost more so i need to know which options are selected. Now the options are listed printed as follows:

(beware im not the neatest coder alive wink )

<table>
<% $count = 0
for option in product.options %>
<% if count =! 2 %>
<tr>
<% end %>
  <td>
  <input type="checkbox"
      id="<%=option.id%>"
    name="options_ids[]"
    value="<%=option.id%>"
  > <%=option.naam%></td><% $count = $count + 1
  if $count == 2
  $count = 0 %>
  </tr>
  <% end %>
  <% end %></table>

Now i need to find a way to submit this array into the ajax, to do this i was suggested by some more experienced users to try the following:

<%= observe_field("format[id]",
   :frequency => 0.25,
   :update => "infoprijs",
   :url => { :action => :getprijs },
   :with => "Form.serialize('bestel')"
   ) %>

Now i for some reason get a javascript error telling me that it's expecting a { now i have no idea why this error is beeing trown at me currently.

The second problem is that the price also needs to update when one of the multiple possible options is changed. Meaning something like:

<%= observe_field("options_ids[]",
   :frequency => 0.25,
   :update => "infoprijs",
   :url => { :action => :getprijs },
   :with => "Form.serialize('bestel')"
   ) %>

Now since i'm a big believer into solving one problem at a time i have tested this but i'm some how doubting that that would work.

Any guru that could shine it's light on this problem? smile

Thanks,

F.B. ten Kate

Last edited by F.B. ten Kate (2006-12-12 08:41:02)