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

  • SEARCH
  • Home
  • 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 7937367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:30:24+00:00 2026-06-03T22:30:24+00:00

I have a form that is used to add an item where 2 dropdowns

  • 0

I have a form that is used to add an item where 2 dropdowns are populated using different database than the database where the form will be submitted. I would like to add AJAX to the drop downs where selecting one item in the first drop down will auto populate data in the 2nd drop down using AJAX. The issue is that I am using the same view for the form to populate the data and its not working even though I m using the is.ajax() call.

Here is my AJAX code:

function get_data(){
//  alert('test');
new Ajax.Request('/abc/abc/add', { 
method: 'POST',
parameters: $H({'type':$('id_data').getValue()},
                            {'csrfmiddlewaretoken':$( "csrfmiddlewaretoken" ).getValue()}),
onSuccess: function(transport) {
    var e = $('id_def')
    if(transport.responseText)
        e.update(transport.responseText)
}
}); // end new Ajax.Request
//alert($( "csrfmiddlewaretoken" ).getValue()); 
}

Here is my view code:

if request.is_ajax():
#if request.is_ajax()
    cur = connections['data'].cursor()
    #auto_type = Auto.objects.filter(type=request.POST.get('type', ''))
    abctype = request.POST.get('type', '')
    SQL = 'SELECT uuid FROM abc_abc where uid  = %s', abctype
    cur.execute(SQL)
    auto_type =cur.fetchone()




    cur = connections['data'].cursor()
    SQL = 'SELECT uuid, name FROM abc_abc where parent_id  = %s', auto_type
    cur.execute(SQL)
    colors = cur.fetchall()
    return render_to_response('abc/add_abc.html', {
            'colors' : colors,
            }, context_instance=RequestContext(request))

Is there anything else that I m missing? Please let me know if you would like me to add some more things from the code…..Please help!!

  • 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-03T22:30:25+00:00Added an answer on June 3, 2026 at 10:30 pm

    I got it to work. Seems liked on the js file I was sending the 2nd parameter after the parameter list. Here is the new code:

    function get_data(){
    new Ajax.Request('/abc/abc/add', { 
    method: 'POST',
    parameters: $H({'type':$('id_data').getValue(), 
                    'csrftoken':$( "csrftoken" ).getValue()
                     }),
    onSuccess: function(transport) {
    var e = $('id_data1')
    if(transport.responseText)
          e.update(transport.responseText)
    }
    
    }); // end new Ajax.Request
    }
    

    Here is my view:

    if request.is_ajax():
        cur = connections['data'].cursor()
        SQL = 'SELECT uuid, name FROM abc_abc where parent_id  = %s'
        auto_type = request.POST.get('type','')
        conv = iri_to_uri(auto_type)
        conv2 = (conv,)
        cur.execute(SQL,conv2)
        colors = dictfetchall(cur)
        return render_to_response('abc/add.html', {
                'colors' : colors,
                }, context_instance=RequestContext(request))
    

    Here is the html obejct:

    <table border="0" cellpadding="0" cellspacing="0">
            <tr>{{ form.abc.errors }}</tr>
            <tr>
                <th><label>ABC:</label></th>
                <td><select name="abc" id="id_abc">
      <option value="" selected="selected">---------</option>
     {% for c in colors %}
    <option value="{{ c.uuid }}">{{ c.name }}</option>
        {% endfor %}
    </select></td>
                <td></td>
            </tr>
        </table>
        <br>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that will not open in the designer. I used the
I have created one web app using mvc and in that used form authentication
Using Symfony 1.3 I have a normal form-filter that is used to filter values
I have created a form that is used for both adding and editing a
I have a form that when submitted successfully generates new elements on the page
I have a form that allows a user to add an unlimited number of
I am very new to PHP; ADD.PHP - I have a form that collects
I would like to create a form that changes dynamically. I have a form
I have PHP code that is used to add variables to a session: <?php
I have a form that submits to a jQuery plugin I've written and used

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.