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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:30:00+00:00 2026-06-12T00:30:00+00:00

I need to POST a form to a CMS and that CMS has specific

  • 0

I need to POST a form to a CMS and that CMS has specific fields for Alimony, Child Support, Insurance, etc. My problem is that in my form, not all of these boxes exist until the user adds it or selects it from the dropdown.

At first there is a select box named “selectBox” that has all of these options inside of it. If the user selects “Alimony” I want the name of the corresponding textbox the change to “payment_alimony” so when I make the POST, the fields match up to the CMS.

Next, if the user needs to add another expense, he will click “Add an Expense” and a select box pops up named “selectBox2” and so on up to 10.

I would prefer to be able to do this without having to have 10 separate functions for each selectBox if possible.

Thank you for your assistance!

<div id="income1" class="row clonedInput"><!-- Expandable Section: INCOME -->
                                <div class="item" id="item_income_source">
                                    <label for="income_source">Additional Income Source<a href="javascript:;" class="tooltip" title="Help Text Goes Here"></a></label>
                                    <select id="income_source" name="income_source"   >
                                        <option value="" selected="selected">- select -</option>
                                        <option value="alimony">Alimony</option>
                                        <option value="child_support">Child Support</option>
                                        <option value="disability">Disability</option>
                                        <option value="social_security">Social Security</option>
                                        <option value="pension">Pension</option>
                                        <option value="rental_protperty">Rental Property</option>
                                        <option value="other">Other</option>
                                    </select>
                                </div>
                                <div class="item small-item third ">
                                    <label for="blank-space">&nbsp;</label>
                                </div>
                                <div class="item small-item third last" id="item_input_gross">
                                    <label for="input_gross">Amount ($)</label>
                                    <input type="text" id="input_gross" value="" name="input_gross" onkeyup="formatInt(this)" onChange="addIncome();" onclick="select();" class="IncometoAdd"  />
                                </div>
                            </div>
                            <div style="clear:both">
                                <input type="button" id="btnAdd-Income" value="(+) add source" />
                                <input type="button" id="btnDel-Income" value="(-) remove source" />
                            </div>

And the Javascript that duplicates:

$(function(){
// Add new element
$('#btnAdd-Income').click(function() {
    var num     = $('.clonedInput').length;
    var newNum  = new Number(num + 1);

    // create the new element via clone(), and manipulate it's ID using newNum value
    var newElem = $('#income' + num).clone().attr('id', 'income' + newNum);

    // manipulate the name/id values of the input inside the new element
    newElem.find('#item_income_source label').attr('for', 'income_source' + newNum);
    newElem.find('#item_income_source select').attr('id', 'income_source' + newNum).attr('name', 'income_source' + newNum).val('');
    newElem.find('#item_input_gross label').attr('for', 'input_gross' + newNum);
    newElem.find('#item_input_gross input').attr('id', 'input_gross' + newNum).attr('name', 'input_gross' + newNum).val('');

    // insert the new element after the last "duplicatable" input field
    $('#income' + num).after(newElem);

    // enable the "remove" button
    $('#btnDel-Income').show();

    // Limit 6 sources  ***EDITABLE***
    if (newNum == 6)
        $('#btnAdd-Income').hide();
});

    // remove the last element
$('#btnDel-Income').click(function() {
    var num = $('.clonedInput').length; // how many "duplicatable" input fields we currently have
    $('#income' + num).remove();        // remove the last element
    addIncome();

    // enable the "add" button
    $('#btnAdd-Income').show();

    // if only one element remains, disable the "remove" button
    if (num-1 == 1)
        $('#btnDel-Income').hide();
});

$('#btnDel-Income').hide();

});

  • 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-12T00:30:02+00:00Added an answer on June 12, 2026 at 12:30 am

    This will work:

    $(function() {
      $('#btnAdd-Income').click(function() {
          source = $('.item').first().clone();
          source.find('input').val('');
          $('.item').last().after(source);
      });
    
      $('.item select').live('change', function() {
          name = $('option:selected',this).val();
         $('input.amount', $(this).closest('.item')).attr('name', name); 
      });
    });​
    

    HTML:

    <div class="item" id="item_income_source">
        <label for="income_source">Additional Income Source<a href="#" class="tooltip" title="Help Text Goes Here"></a></label>
        <select id="income_source" name="income_source"   >
         <option value="" selected="selected">- select -</option>
         <option value="alimony">Alimony</option>
         <option value="child_support">Child Support</option>
         <option value="disability">Disability</option>
         <option value="social_security">Social Security</option>
         <option value="pension">Pension</option>
         <option value="rental_protperty">Rental Property</option>
         <option value="other">Other</option>
       </select>
    
      <label for="input_gross">Amount ($)</label>
      <input type="text" id="input_gross" class="amount"    />
     <br>
    </div>
    </div>
    <div style="clear:both">
     <input type="button" id="btnAdd-Income" value="(+) add source" />
     <input type="button" id="btnDel-Income" value="(-) remove source" />
    </div>
    

    jsFiddle: http://jsfiddle.net/ft6ME/32/

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

Sidebar

Related Questions

I have a url (http://www2.anac.gov.br/aeronaves/cons_rab.asp) where I need to post form data programatically. That
I'm having a problem accessing a Django Form POST data. I need to pass
I need to post a form on a new website which is UTF-8 encoded.
I've got a form and I need to post data to the server every
does curl function need any special option to post multipart/form-data ?
I have a base Twig template that has a search bar form in it
I have post form with submit button before submit i need to call c#
I am using FCKEditor in a CMS and need to post some javascript code
I'm debugging an html form. I need to POST the form with the default
using a drop-down list that's populated from database fields, i need to select an

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.