Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8734789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:54:59+00:00 2026-06-13T09:54:59+00:00

I have a dropdown in view that is using js I pass the selected

  • 0

I have a dropdown in view that is using js I pass the selected item from dropdown to controller, inside the controller I ran a query using the selected item from dropdown to extract some records. Now the problem is that I cannot display the query result to view. Basically I cannot trigger the controller to display in view. Any help greatly appreciated.

Here is the js to pass the data to controller:

<script type="text/JavaScript">
$(function(){
    $('.defined_call').bind('change', function(){
        alert($(this).val());
        $.ajax({
            url: "<%= changeowner_path %>",
            data: { my_str: $(this).val() }
        });
    });
});
</script>

<%= select_tag "dropdown_cases", options_for_select(@ownerlist),{:id=>"defined_Id",:class 
=> "defined_call'}  %>

Here is the controller:

class ReassignsController < ApplicationController
  def changeowner
    i=0
    $myarr=[]
    ownerl = Transaction.owner#declaredin model
    @ownerlist=ownerl.collect { |c| [ c, c ] }#make it for dropdown
    value=params[:my_str]#return value from dropdown
    $value1=value.to_s#make it for owner table
    @owner_records=Transaction.where(:owner => $value1) 

    ===> I would like to display to the view?
  end
end

Here is the view that I am using:

<table class="table table-condensed" id="sortTableExample">
<tr>
<th style="text-align:center">Book Name</th>
<th style="text-align:center">Owner</th>

</tr>

<% @owner_records.each do |arr_data| %>
<tr>
<td style="text-align:center"><%= arr_data.book%></td>
<td style="text-align:center"><%= arr_data.owner%></td>
</tr>
<% end %>
</table>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:55:00+00:00Added an answer on June 13, 2026 at 9:55 am

    Joe, Try something like:

      $('.defined_call').change(function() {
            $.ajax({
                url: "<%= changeowner_path %>", type: 'get', 
                data: { my_str: $(this).val() },
                dataType: 'json',
                processData: false,
                success: function(data) {
                  if (data == "") {
                    alert('No Results');
                  }
                  else {
                    var jsonObj = eval( data );
                    var count = jsonObj.transactions.length;
                    for (var i = 0; i<count; i=i+1) {
                      $('#sortTableExample').append('<td style="text-align:center">' + jsonObj.transactions[i].book + '</td><td style="text-align:center">' + jsonObj.transactions[i].owner + '</td>');
                    }
                  }
                }
            });
      });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view with 1 dropdown generated from Model property and 3 additional
In my ASP.net MVC View I have a dropdown that I want to get
I have a view, that is of Inherits from System.Web.Mvc.ViewPage<P> . Type P has
I'm using Seleniunm to test my webpage. I have a dropdown box that I
I have a view that list Parts in a htmltable format from a database
I have a partial view that I'm using on my index page to display
I have an image inside a partial view that will ultimately be changed by
I am using Codeigntier and I have the following dropdown in my view file
I have a view where I use a dropdown list with enum: public enum
I have dropdown menu..which is dynamic.. How can get value of the last item

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.