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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:11:20+00:00 2026-05-13T23:11:20+00:00

I have some javascript which catches changes to a form then calls the form’s

  • 0

I have some javascript which catches changes to a form then calls the form’s regular submit function. The form is a GET form (for a search) and i have lots of empty attributes come through in the params. What i’d like to do is to delete any empty attributes before submitting, to get a cleaner url: for example, if someone changes the ‘subject’ select to ‘english’ i want their search url to be

http://localhost:3000/quizzes?subject=English

rather than

http://localhost:3000/quizzes?term=&subject=English&topic=&age_group_id=&difficulty_id=&made_by=&order=&style=

as it is at the moment. This is just purely for the purpose of having a cleaner and more meaningful url to link to and for people’s bookmarks etc. So, what i need is something along these lines, but this isn’t right as i’m not editing the actual form but a js object made from the form’s params:

  quizSearchForm = jQuery("#searchForm");
  formParams = quizSearchForm.serializeArray();
  //remove any empty fields from the form params before submitting, for a cleaner url
  //this won't work as we're not changing the form, just an object made from it.
  for (i in formParams) {
    if (formParams[i] === null || formParams[i] === "") {
      delete formParams[i];
    }
  }
  //submit the form

I think i’m close with this, but i’m missing the step of how to edit the actual form’s attributes rather than make another object and edit that.

grateful for any advice – max

EDIT – SOLVED – thanks to the many people who posted about this. Here’s what i have, which seems to work perfectly.

function submitSearchForm(){
  quizSearchForm = jQuery("#searchForm");
  //disable empty fields so they don't clutter up the url
  quizSearchForm.find(':input[value=""]').attr('disabled', true);
  quizSearchForm.submit();
}
  • 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-05-13T23:11:20+00:00Added an answer on May 13, 2026 at 11:11 pm

    The inputs with attribute disabled set to true won’t be submitted with the form. So in one jQuery line:

    $(':input[value=""]').attr('disabled', true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 538k
  • Answers 538k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer All of the information you are looking for can be… May 17, 2026 at 2:04 am
  • Editorial Team
    Editorial Team added an answer You can use Buffer.BlockCopy to do this very efficiently: using… May 17, 2026 at 2:04 am
  • Editorial Team
    Editorial Team added an answer Ach - terribly embarrassing - 30 mins after posting I… May 17, 2026 at 2:04 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have some Javascript which animates a colour change on an HTML element, as
I have some JavaScript which is changing an image correctly but once it has
I have some javascript which parses an ISO-8601 date. For some reason, it is
I have some javascript which runs a timer that animates something on the website.
Let's say I have some HTML and Javascript which adds text fields dynamically to
I have some javascript which will create some sort of widget on a page.
I have some javascript code that is used in a few different pages in
We have some JavaScript code that resizes <div/> elements (adjusts height/width/padding/margin etc.) based on
I would like to have some Javascript code running in a web browser write
I have some troubles with memory leaks in JavaScript. I'm using the Leak Memory

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.