Hey can you please use some service like pastie.org to paste the code and
give us the link ?
Reading this code gives me a headache ...

Thanks & Regards,
Dhruva Sagar.


Jonathan Swift<http://www.brainyquote.com/quotes/authors/j/jonathan_swift.html>
- "May you live every day of your life."

On Sat, Aug 29, 2009 at 1:39 PM, Quee Mm
<[email protected]>wrote:

>
> man i have so many different combos but here is my latest code.
>
> In my view I have
> <code>
> <%= f.select(:year_made, ((1980..Time.now.year).collect {|p| [ p, p
> ]}).reverse, {:prompt=>"Select a Year"}) %>
> <%= f.select(:year_imported, ((1980..Time.now.year).collect {|p| [ p, p
> ]}).reverse, :prompt=>"Select a Year") %>
> <%= f.select(:year_registered, ((1980..Time.now.year).collect {|p| [ p,
> p ]}).reverse, :prompt=>"Select a Year") %>
> </code>
> then i am using JavaScript to control what the drop downs will show..
> <code>
>  jQuery('#vehicle_year_made').change(function(){
>    year_made_id = jQuery("#vehicle_year_made :selected").val();
>    if (year_made_id  != "" ) {
>      var currentTime = new Date()
>      var options = '<option>Select a Year</option><option
> value="Local">Local</option>';
>      for (i=currentTime.getFullYear(); i >= year_made_id; i--) {
>        options += '<option value="' + i + '">' + i + '</option>';
>      }
>      jQuery("#vehicle_year_imported").html(options);
>      jQuery("#vehicle_year_imported").removeAttr("disabled");
>
>      jQuery('#vehicle_year_imported').change(function(){
>        if ( jQuery("#vehicle_year_imported :selected").val() == "" ||
> jQuery("#vehicle_year_imported :selected").val() == "Select a Year")
>        {
>          jQuery("#vehicle_year_registered").attr("disabled",
> "disabled");
>        }
>        year_import_id  = jQuery("#vehicle_year_imported
> :selected").val();
>        if (year_import_id != "Select a Year" && year_import_id !=
> "Local") {
>          var options = '<option>Select a Year</option><option
> value="Un-Registered">Un-Registered</option>';
>          for (i=currentTime.getFullYear(); i >= year_import_id; i--) {
>            options += '<option value="' + i + '">' + i + '</option>';
>          }
>          jQuery("#vehicle_year_registered").html(options);
>          if (options != '<option>Select a Year</option>') {
>            jQuery("#vehicle_year_registered").removeAttr("disabled");
>          }
>        }
>        else if (year_import_id == "Local") {
>          var options = '<option>Select a Year</option><option
> value="Un-Registered">Un-Registered</option>';
>          for (i=currentTime.getFullYear(); i >= year_made_id; i--) {
>            options += '<option value="' + i + '">' + i + '</option>';
>          }
>          jQuery("#vehicle_year_registered").html(options);
>          if (options != '<option>Select a Year</option>') {
>            jQuery("#vehicle_year_registered").removeAttr("disabled");
>          }
>        }
>        else
>        {
>          options = '<option>Select a Year</option>';
>          jQuery("#vehicle_year_registered").html(options);
>          jQuery("#vehicle_year_registered").attr("disabled",
> "disabled");
>        }
>      });
>
>    }
>    else
>    {
>      options = '<option>Select a Year</option>';
>      jQuery("#vehicle_year_imported").html(options);
>      jQuery("#vehicle_year_imported").attr("disabled", "disabled");
>      jQuery("#vehicle_year_registered").html(options);
>      jQuery("#vehicle_year_registered").attr("disabled", "disabled");
>    }
>  });
> </code>
>
> This works perfectly fine at new but when i edit a record the JavaScript
> does not seem to work and all drop downs show 2009 - 1980 as options.
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to