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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:43:55+00:00 2026-05-13T18:43:55+00:00

I have a form containing some dynamic elements. These are basically text input boxes

  • 0

I have a form containing some dynamic elements. These are basically text input boxes that will contain phone numbers with a button to the right to delete the element.
Another button adds a new element and the final one to save it to the database.
What I’m wanting to do is to “mark” numbers that have changed, been removed or new numbers.
So that I can do a update, insert or delete on the database as I don’t want to delete all and insert all each time in the database.

The delDisaNumber isn’t quite what I want… I want to hide the element so I can mark it as deleted. But doing so makes it appear like the form gets submitted. On the other hand, using .remove visibly behaves how I want it to, but removes the element completely which is not what I want (I want it hidden).

Here is the code in question so far. (this is written in jquery and php using kohana)

<script type="text/javascript">
  var disaId = 1;

  function setModified(element){
    $(element).attr('name', 'update');
  }

  function delDisaNumber(element){
      $(element).prev('name','delete');
      $(element).parent().remove();  /* has the effect I want, but removes the element */
      // $(element).parent().hide() /* this is what I want but submits the form */
  }

  function addDisaNumber(){
      $("#disa_numbers").append('<li id="disa_num"'+disaId+'><input /><button onClick="delDisaNumber">X</button></li>');
    $disaId++;
  }
  </script>

  ...

<div id="disa">
  <?php
    echo form::open("edit/saveDisaNumbers/".$phone, array("class"=>"section", "id"=>"other"));
    echo form::open_fieldset(array("class"=>"balanced-grid"));
  ?>
  <ul class="fields" id="disa_numbers">
    <?php
      $disaId = 1;
        foreach ( $disa_numbers as $disa_number ){
           $disaid_name = 'disa_num'.$disaId;
           echo '<li id="'.$disaid_name.'">';
           echo form::input("disa".$disaId, $disa_number->cid_in, "onKeyDown='setModified(this)'");
           echo form::button("",'X','onClick="delDisaNumber(this)" class="button image"');
           echo "</li>";
           $disaId++;
        }
     ?>   
    </ul>
    <button type="button" onclick="addDisaNumber()">Add another number</button>
    <?php
      echo form::submit('submit', 'Save');
      echo form::close();
    ?>
</div>

EDIT: It seems that form::button isn’t behaving as expected. If I replace it with echo ‘X’ it doesn’t post the form.

  • 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-13T18:43:55+00:00Added an answer on May 13, 2026 at 6:43 pm

    My suggestion is that instead of changing the name, add a class like “modified”. And then submit only those.

    $("form").submit(function() {
      $("input:not(.modified)").attr("disabled", true);
    });
    

    How this works is that disabled input elements aren’t submitted to the server.

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

Sidebar

Related Questions

I have a simple form containing a main view and also some text boxes
I have a form containing two text boxes for user input. Both text boxes
I have a dl containing some input boxes that I clone with a bit
I have a simple in VB/ASP.NET form containing two text boxes, I am attempting
I have a wicket form containing a FileUploadField and some more text fields. When
I have a form containing a list of input fields that the user populates
I have form containing a Clear Button, usercontrol. The userControl has some text box
I have a listener for 3 DIV's containing several form elements: <div id=div-a> <input
Fact: I'm not that good with jQuery. Problem: I have a form containing dynamically
I have a HTML form containing checkboxes in the form of .. <input type=checkbox

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.