How to pass the select box value as an array using AJAX from one page to another in PHP?

Balsara Dhaval
var message = $("#send_message").val();

    var Teaminput = $("#sms_reminder_team").val();
    for (var i = 0; i <Teaminput.length; i++) 
    {
       var team=Teaminput[i];
    }

    var Memberinput = $("#sms_reminder_members").val();
    for (var i = 0; i <Memberinput.length; i++) 
    {
    var members=Memberinput[i];

  }

Get 2 varaibles as array members and team

var parameter = "message="+message+"&team="+team+"&members="+members;
  $.ajax({
  url: base_url+'ajaxfiles/dir_sendmessage',
  type: 'POST',
  data: parameter,
  success: function(data)
  {
    document.getElementById('check').innerHTML = data; 
  }
  });

How to send both array variables using AJAX from current page to "dir_sendmessage".

Arun

Change the below line

var parameter = "message="+message+"&team="+team+"&members="+members;

to

var parameter = "message="+message+"&team="+JSON.stringify(team)+"&members="+JSON.stringify(members); 

Edit: Modify like this too

var team = [];
var members = [];
for (var i = 0; i <Teaminput.length; i++) 
{
   team=Teaminput[i];
}

var Memberinput = $("#sms_reminder_members").val();
for (var i = 0; i <Memberinput.length; i++) 
{
   members=Memberinput[i];
}

Note: When you add var in each line in the loop, it will declare a new variable. You have to edit like the above code

After update the code with the JSON.stringify() function, you will be able to get the value as an array in you PHP code

Ajax will not directly pass Jquery array to PHP

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to get data from one php page using ajax and pass it to another php page using ajax

From Dev

Pass data from one PHP page to another using ajax

From Dev

How to pass select box value with array and store in Database using php

From Dev

php select array value and pass it to another page

From Dev

How to pass two value from one page to another in php, passing using session

From Dev

Pass Search value from one html page text box to another html page text box on click using cookies?

From Dev

how to pass value one page to another page using html

From Dev

how to pass the value from one page to another page in angular?

From Dev

how to pass the value from one page to another page in html

From Dev

How to pass user input value from a PHP page to HTML page using AJAX

From Dev

How to pass user input value from a PHP page to HTML page using AJAX

From Dev

How to pass a value from one jsp to another jsp page?

From Dev

How to pass data from one html page to another using javascript?

From Dev

How To Pass Form Data from One Page To Another using FlaskApp

From Dev

Angularjs pass value from one page to another

From Dev

how to pass value to another php page using href

From Dev

how to pass ajax response value to another page?

From Dev

How to send GET value and php available to another page using ajax?

From Dev

How to carry session value from one page to another in php?

From Java

Select a value from a select box and auto select a value from another select box using jquery

From Dev

How to pass a value from PHP to Javascript without using Ajax?

From Dev

how to add value from one combo box to another combo box

From Dev

pass data from remote loaded content to another php page using ajax

From Dev

how to pass json response from one html page to another html page using angularJs?

From Dev

Using jquery.when and done to pass a value from one ajax call to another

From Dev

Getting an array created in one PHP page from another PHP page?

From Dev

How to use data from one HTML page to retrieve data to be used on another HTML page using ajax

From Dev

How to pass data from one page to another page html

From Dev

How to pass form fields from one page to another page in ReactJS?

Related Related

  1. 1

    How to get data from one php page using ajax and pass it to another php page using ajax

  2. 2

    Pass data from one PHP page to another using ajax

  3. 3

    How to pass select box value with array and store in Database using php

  4. 4

    php select array value and pass it to another page

  5. 5

    How to pass two value from one page to another in php, passing using session

  6. 6

    Pass Search value from one html page text box to another html page text box on click using cookies?

  7. 7

    how to pass value one page to another page using html

  8. 8

    how to pass the value from one page to another page in angular?

  9. 9

    how to pass the value from one page to another page in html

  10. 10

    How to pass user input value from a PHP page to HTML page using AJAX

  11. 11

    How to pass user input value from a PHP page to HTML page using AJAX

  12. 12

    How to pass a value from one jsp to another jsp page?

  13. 13

    How to pass data from one html page to another using javascript?

  14. 14

    How To Pass Form Data from One Page To Another using FlaskApp

  15. 15

    Angularjs pass value from one page to another

  16. 16

    how to pass value to another php page using href

  17. 17

    how to pass ajax response value to another page?

  18. 18

    How to send GET value and php available to another page using ajax?

  19. 19

    How to carry session value from one page to another in php?

  20. 20

    Select a value from a select box and auto select a value from another select box using jquery

  21. 21

    How to pass a value from PHP to Javascript without using Ajax?

  22. 22

    how to add value from one combo box to another combo box

  23. 23

    pass data from remote loaded content to another php page using ajax

  24. 24

    how to pass json response from one html page to another html page using angularJs?

  25. 25

    Using jquery.when and done to pass a value from one ajax call to another

  26. 26

    Getting an array created in one PHP page from another PHP page?

  27. 27

    How to use data from one HTML page to retrieve data to be used on another HTML page using ajax

  28. 28

    How to pass data from one page to another page html

  29. 29

    How to pass form fields from one page to another page in ReactJS?

HotTag

Archive