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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:46:43+00:00 2026-06-16T14:46:43+00:00

In the form below, I change the action attribute and submit the form. That

  • 0

In the form below, I change the action attribute and submit the form. That works fine. What goes on is: if the current location is http://localhost/search/?mod=all and the search term is 14, the action will be changed to http://localhost/search/?mod=all&handle=14 and so will the url in the browser.

But the next time I try to search, since the url now is http://localhost/search/?mod=all&handle=14, I get http://localhost/search/?mod=all&handle=14&handle=15. It’ll keep going on and on with each search term.

Any idea how I can retain the orginal url http://localhost/search/?mod=all through this all.

Here’s the form:

<form method="GET" class="modForm" action="">
<input type="text" placeholder="Search" class="modSearchValue">
<input type="radio" name="text" value="text" class="text" title="Search">
</form>

Here’s the jquery:

$('.modForm').submit(function(event) {
  var $this = $(this);
  var query = $this.find('.modSearchValue').val(); // Use val() instead of attr('value').
  var locale = window.location;
  if ($('.text').is(':checked')) {
    query = '&text=' + query;
  } else {
    query = '&handle=' + query;
  }
  route = locale + query;
  console.log(route);
  if (query.length >= 1) {
    // Use URI encoding
    var newAction = (route);
    console.log(newAction); // DEBUG
    // Change action attribute
    $this.attr('action', newAction);
    //event.preventDefault();
  } else {
    console.log('Invalid search terms'); // DEBUG
    // Do not submit the form
    event.preventDefault();
  }
});
  • 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-16T14:46:45+00:00Added an answer on June 16, 2026 at 2:46 pm

    There are few ways to do it. I would rather not mess with window.location and do something simpler:

    <form method="GET" class="modForm" action="">
        <input type="hidden" name="mod" value="all"> <!-- mod is a hidden variable -->
        <input type="text" id="modSearchValue">      <!-- name not defined yet -->
        <input type="checkbox" id="textOrHandle">    <!-- name not required -->
    </form>
    
    $(".modForm").submit(function() {
        $("#modSearchValue").attr("name", $("#textOrHandle").is(":checked") ? "text" : "handle");
        // let the form submit!
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below is the code that I am currently using: $form = <form action='echo htmlentities($_SERVER[PHP_SELF]);'
I'd like to take my form below, and somehow adjust it to submit the
Below is a script that is run when a Change Password button is clicked
I want to submit search term ( e.g what does foo means) into form
My script: <script language=JavaScript> function submitform() { document.playsong.submit(); } </script> Submits the below form:
I would like to change the URL that appears once a form has been
I have a simple page (below) with a form. The form will submit if
The form below is working as I want except for one thing. When I
For the form below, how could I make the input field big, like maybe
In the dialog form below, I have 2 buttons: Save & Cancel. When user

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.