3

I have the following javascript:

<script type="text/javascript" charset="utf-8"> $(function() { $( "#slider-range" ).slider({ range: true, min: 200, max: 2000, values: [ 800, 1200 ], slide: function( event, ui ) { $( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] ); } }); $( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) + " - $" + $( "#slider-range" ).slider( "values", 1 ) ); }); 

The code creates a price range and a slider bar, price range slides as user moves bar. I want to pass the min price and max price into the form like:

<%= form_tag laptops_path, :method => 'get' do %> <%= hidden_field_tag "amount", params[:amount] %> <%= submit_tag "Search", :name => nil %> 

But when I do so, the "amount" is still coming blank when submitted. Any ideas why?

3
  • Good details! Very well formed question.
    – slm
    CommentedDec 22, 2012 at 3:25
  • Thre eseems to be no problem at the first look. Can you please check whether your amount element in GUI is updated to required value?
    – LPD
    CommentedDec 22, 2012 at 4:02
  • I sense sarcasm from slm. :)CommentedDec 22, 2012 at 4:24

1 Answer 1

2

Make sure that your input element has an id attribute (not just name attribue). #amount means nothing without the id attribute (however, you could use: input[name=amount], if that's the problem).

0

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.