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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:23:39+00:00 2026-06-18T23:23:39+00:00

If I have a dynamic element like this: http://jsfiddle.net/kfm5b/2/ <select name=roomFac1 id=roomFac1> <option selected=selected>Any</option>

  • 0

If I have a dynamic element like this: http://jsfiddle.net/kfm5b/2/

<select name="roomFac1" id="roomFac1">
  <option selected="selected">Any</option>
</select>
<input type="button" value="Add" class="pmbtn" id="addFac"/>
<input type="button" value="Remove" class="pmbtn" id="removeFac"/>

$(document).ready(function(){
    $('#addFac').click(function(){
        var $objs = $('select[name*=roomFac]');
        var n = $objs.size() + 1;
        var $obj = $objs.first().clone();
        $obj.attr('name', 'roomFac'+n).attr('id', 'roomFac'+n);
        $obj.appendTo($('body'));
    });
    $('#removeFac').click(function(){
        var $objs = $('select[name*=roomFac]');
        if($objs.size() > 1){
           $objs.last().remove();
        }
    });
});

How would I fetch its output for use in an AJAX submission once the user clicks the submit button e.g.

$("#submit").click(function () {
...
...
var dataString = ....; // how I would I implement the dynamically created elements here s I don't know the size
...
...
$.ajax({
    type: "POST",
    url: "process.php",
    data: dataString,
    cache: false,
    success: function (html) {
        $('#search_room').html(html);
    }
});

Secondly, what would I put in the PHP document handling the processing?

  • 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-18T23:23:40+00:00Added an answer on June 18, 2026 at 11:23 pm

    Considering you need to put values of all the selected elements in the dataString.

        $("#submit").click(function () {
    
        var dataString = "";
    
            $('select[name*=roomFac]').each(function(){
                dataString+=$(this).val();
                dataString+=",";
            });
    
            $.ajax({
                type: "POST",
                url: "process.php",
                data: dataString.substring(0, dataString.length - 1);,
                cache: false,
                success: function (html) {
                    $('#search_room').html(html);
                }
            });
        });
    

    On php side :

        $dataFromClient = $_POST['data'];
        $dataFromClient = explode(',',$dataFromClient);
    
    //now $dataFromClient  will be an array that contains all the values.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some dynamic buttons that look like this: <input type=button name=button id=button value=Click
Using Drupal 6.20. We can setup some form elements like this:- <input type=select name=somename[]><option>ohai</option></select>
Possible Duplicate: Dynamic object property name I have an object like this var localAppConfig
I have dynamic content in a div called txtresults like this: <div id=txtresults></div> This
I have an xml like this <?xml version=1.0 encoding=UTF-8 ?> <product> <productname> ----->Dynamic node
http://fiddle.jshell.net/kBFU7/2/ In the code, I have created a dynamic table through jQuery. I also
I have a parent element that has dynamic text in it that needs to
I have a dynamic URL (http://domain.com/getUsers.php?team=1) that if its manually accessed, returns some Json
my html is like this <td> <input type=text class=textinput id=file_descr_0 name=file_descr[0] value='' /> <div
Let's say I have objects which look very roughly like this: class object {

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.