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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:27:57+00:00 2026-06-12T01:27:57+00:00

I have a form that I want to only submit post data for value

  • 0

I have a form that I want to only submit post data for value which have changed.

So the way I have been doing this is like this:

function submit_form(){
var hd = [];
// hd is a big array that is defined here
// hd ['some id_number'] = 'some value'
// main function
for (var id_number in hd ){
    var x=document.getElementById(id_number).selectedIndex;
    var y=document.getElementById(id_number).options;
    selector_text = y[x].text;
    if (hd[id_number] == selector_text){
        $(id_number).remove();
    }
}
document.forms["my_form"].submit()
}

So the goal is that if the selector equals what is in the array, then don’t POST the data.

To do this I have been doing the remove function. Everything up to the remove function works as expected. However when I look at the post data I still get the selected value for the id_numbers that mach the value in hd.

Is there a better way to remove to prevent it from going to the POST data? The id.parent.removeChild(id) method didn’t work either.

  • 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-12T01:27:58+00:00Added an answer on June 12, 2026 at 1:27 am

    The jQuery id selector should begin with a #, but yours appears not to:

     $('#' + id_number).remove();
    

    Your for-in loop should be a regular incremental for loop, which is the proper way to iterate an array in JavaScript. for-in loops are typically used for iterating object properties rather than array elements.

    for (var i=0; i<hd.length; i++) {
      // Access hd[i] in the loop
    
      var x=document.getElementById(hd[i]).selectedIndex;
      var y=document.getElementById(hd[i]).options;
    
      selector_text = y[x].text;
    
      if (hd[i] == selector_text){
         $('#' + hd[i]).remove();
      }
    }
    

    Since you aren’t really using jQuery here except for that line, instead the plain JS version is:

    var removeMe = document.getElementById(hd[i]);
    removeMe.parentNode.removeChild(removeMe);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this select input in my form that I want to access via
I have a form that does not seem to want to write its data
I have this form, with 2 submit buttons: <form method=post onsubmit=send_mail(this);return false> <select name=liste>
I have a form that I want to be validated before showing it initially.
I have a form that i want to appear at the top of every
I have a form that i want an administrator to fill out, then click
I have a form that i want to auto populate the last 2 fields
Okay all, I have a form that I want users to fill out. When
I have a small form that I want to have people fill out on
I want to have a Form that can Add or Delete TextFields. I was

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.