Customising url

Hi,
In my web application i need to select date and and vendor to display
the corresponding data
When i select the date, it doesn’t get displayed in the url i.e the url
remains the same
but when i select the vendor it appears in the url.

I want that even the vendor shouldn’t get appeared in the url

Please help…

can you post your code?

On Jun 20, 3:03 am, Sneha G. [email protected]

Ajit Singh wrote:

can you post your code?

On Jun 20, 3:03 am, Sneha G. <[email protected]

The code for the partial used in this attachment is

for vendor list is

<%= error_messages_for ‘contract’ %>

<%=

vendors = []
@contracts_vendor.each do |contract|
vendors << contract.vendor

end

select_tag "vendor",
  options_for_select(
    vendors,
    session[:selected_vendor] ),
     {:onchange=> link ,
      :id=>"ctrlContent_ct200_VendorList",
      :name=>"ctrlContent$ct200$VendorList",
}

%>

and the partial for selecting the date is as

<%=
d = Date.today
dates = []
15.times do
dates << [d.strftime("%B %Y"), d.strftime("%Y%m")]
d = d << 1
end
select_tag “month”,
options_for_select(
dates,
session[:selected_month] ),
{:onchange=> link ,
:id=>“ctrlContent_ctl00_MonthList”,
:name=>“ctrlContent$ctl00$MonthList”}
%>

The controller code is for vendor

def set_selected_vendor

if params[:vendor]
  session[:selected_vendor] = params[:vendor]
  @array_vendor = session[:selected_vendor]
  #redirect_to :action=>action_name
  #return false
end
 return true

end

and controller code for date is

def set_selected_month

if params[:month]
  session[:selected_month] = params[:month]
  # redirect back here without the month parameter:
  redirect_to :action=>action_name
  return false
end
unless session[:selected_month]
  @month_start = Date.new(Date.today.year, Date.today.month, 1)
  @month_end = @month_start>>1
  # If it's early in the month (i.e. before the 11th), use last 

month as the default:
if Date.today.day < 11 then @month_start = @month_start<<1 end
session[:selected_month] = @month_start.strftime(’%Y%m’)
end
@month_start = Date.parse session[:selected_month] + “01”
@month_constraints_string = “date >= '” + @month_start.to_s +
“’ AND date < '” + (@month_start>>1).to_s + “’”

return true

end

Please help me out of this.

are you submitting the form ;onchange, ?

if yes then i will suggest you to check post method for both date and
vendor. it should be “post” not “get”. if you havent specified any… i
will recommend to explicitly put form method=“post”

let me know, if this works for you.

Ajit

On Jun 20, 9:33 am, Sneha G. [email protected]

view source for your form in web-browser and post me the source for
form part. if possible?

Ajit

Yes i have already tried using method = “post” ( in controller,views
and partials)
But iam not sure whether i’ve used it correctly or not
Please can you guide me where exactly i should use it

Ajit Singh wrote:

view source for your form in web-browser and post me the source for
form part. if possible?

Ajit

I’ve send you the view source of my browser…

Hi Sneha

I just tested your document… in both of the cases… url is getting
updated.

cant you simple create a form around those two elements and onchange
submit the form

try something like:

function doSomething()
{
form1.element1.value = $F(‘select_one’);
form1.element2.valie = $F(‘select_two’);
form1.submit;
}

<% form :id=>form1, :method => ‘post’ %>
<% hidden_field :id=>element1%>
<% hidden-field :id => element2 %>
<select_tag :id => select_one :onchange => doSomething()><%end%>
<select_tag :onchange => doSomething()>
<% end %>

let me know…

Ajit

On Jun 21, 5:53 am, Sneha G. [email protected]

hmmm…

i dont think that it could be done otherwise. you can explain this to
client… there are only two methods to send information… GET and
POST. explain the difference between these two.

or you can try making an Ajax call.

let me know

On Jun 24, 6:22 am, Sneha G. [email protected]

Ajit Singh wrote:

Hi Sneha

I just tested your document… in both of the cases… url is getting
updated.

cant you simple create a form around those two elements and onchange
submit the form

try something like:

function doSomething()
{
form1.element1.value = $F(‘select_one’);
form1.element2.valie = $F(‘select_two’);
form1.submit;
}

<% form :id=>form1, :method => ‘post’ %>
<% hidden_field :id=>element1%>
<% hidden-field :id => element2 %>
<select_tag :id => select_one :onchange => doSomething()><%end%>
<select_tag :onchange => doSomething()>
<% end %>

let me know…

Ajit

On Jun 21, 5:53 am, Sneha G. [email protected]

Hi Ajit
That’s what my actual problem is
I do not want to use the submit tag
The values should get changed onclick
I cannot use the seperate submit tag to submit the values
Because my client demands that.