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 8960323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:38:14+00:00 2026-06-15T15:38:14+00:00

Caveat: I’m VERY new at both Django and jQuery/Javascript. So far, it’s driving me

  • 0

Caveat: I’m VERY new at both Django and jQuery/Javascript. So far, it’s driving me up a friggin’ wall. I want to create a search page that allows users to select query parameters from a drop-down menu and then enter their query text in a text box. I also want to dynamically create more search bars/drop-down menus. I also want to be able to display notes about the availability of certain drop-down menu options (e.g. “Years may not be available for all records; records without year information will not be displayed without additional parameters.”)

The big headache I’m having right now is that my “more” button seems to be functioning as a “submit” button, for no reason I can see. That is to say, instead of displaying more search forms, clicking the “more” button transfers the stuff in the textbox to the url, like “submit” is supposed to do. I don’t know if it’s an issue with my javascript, or with the way Django handles forms, or what. Like I said, I’m totally wet behind the ears at this stuff, and I’m sure it’s something dumb I’m overlooking, although JSlint says everything is fine. Someone please help me.

Code:

var i, i_str, sel_str, add_form, shownote, changeval, changebool, form_array,more_array, note_array, selected_str;
$(document).ready(function () {
i = 1;
i_str = i.toString();
sel_str = (i - 1).toString();
add_form = function () {
    form_array = [
        '<p><form id="form' + i_str + '" action="" method="get">',
        '<select id="row" name="row">',
        '<option value="dish_name">Name</option>',
        '<option value="year">Year</option>',
        '<option value="period">Five-Year Period</option>',
        '<option value="location">Location</option>',
        '<option value="ingredient">Main Ingredient</option>',
        '<option value="course">Course or Dish Type</option>',
        '</select>',
        '<label for="query">Dish Name</label>',
        '<input type="text" name="dish_name" id="query"></input>',
        '<button id="more">More</button>',
        '<input type="submit" value="Search"></input>'
    ];
    more_array = [
        '<select id="bool" name="bool">',
        '<option value="none" selected="selected">    </option>',
        '<option value="and">AND</option>',
        '<option value="or">OR</option>',
        '<option value="and_not">AND NOT</option>',
        '<option value="or_not">OR NOT</option>',
        '</select>'
    ];
    note_array = [
        '<p class="note"></p>',
        '</form></p>'];
    $("#search").append(form_array.join("\n"));
    $("option:eq(" + sel_str + ")").attr("selected", "selected");
    $("label").text = $(($("this select").val).text);
    $("select#row").change(shownote());
    $("button").click(function () {
        $('input[type="submit"]').hide();
        $(".search").append(more_array.join("\n"));
    });
    i++;
};
$(document).ready(add_form());
});
$(document).ready(function () {
shownote = function () {
    switch ($(this).val) {
    case "year":
        $(".note").append("Note: Year information may not be available for all dishes. Dishes without years will not be returned without additional search criteria.<br />");
        break;
    case "period":
        $(".note").append("Note: Please enter periods in YYYY-YYYY format. Period information may not be available for all dishes. Dishes without periods will not be returned without additional search criteria.<br />");
        break;
    case "location":
        $(".note").append("Note: Location information may not be available for all dishes. Dishes without location information will not be returned without additional search criteria.<br />");
        break;
    }
};
});
$(document).ready(function () {
changeval = function () {
    var changed_to = $("#row").val, get_new_label = function (changed_to) {switch (changed_to) {
    case "dish_name":
        return "Dish Name";
    case "year":
        return "Year";
    case "period":
        return "Five-Year Period";
    case "location":
        return "Location";
    case "ingredient":
        return "Main Ingredient";
    case "course":
        return "Course or Dish Type";
    }
        };
    $('this label[for="query"]').innerHTML = get_new_label(changed_to);
    $('this input[id="query"]').attr("name", changed_to);
};
});
$(document).ready(function () {
changebool = function () {
//something that changes the boolean values of the search string
};
});
$("#form" + i_str + " #row").change(changeval());
$("#form" + i_str + " #row").change(shownote());
  • 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-15T15:38:15+00:00Added an answer on June 15, 2026 at 3:38 pm

    There is a bit I could comment on the structure of both your javascript and output of the markup. This isn’t your request though, but if you want it I’ll be happy to help out.

    To prevent your button from sending:

    <button type='button'>My button<button>
    

    Here is a reference if you are curious:

    A button element with no type attribute specified represents the same
    thing as a button element with its type attribute set to “submit”.

    http://dev.w3.org/html5/markup/button.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Prelim caveat: I am very new to js and have mainly gotten by through
...and are there any other caveat for other platforms? I create an app.config for
Using Python2.4 I want to capture output from a mysql command. One caveat is
Caveat: new to Python. Wanting to hear from professionals who actually use it: What
Django documentation states: The caveat with using variables or computed values, as in the
One caveat of using the inserted and deleted tables is that they can both
First, a caveat: I'm brand new to C#, so please forgive me, if this
Using jQuery Mobile, how could I create hashbang URLs such as #!/value_1/value_2 and be
This is essentially a duplicate of this question but with one caveat: I want
The following code is thread-safe as far as I can tell, with the caveat

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.