-1

I use a HTML form with several fields. But i need to have the value from the select fields ( dropdown ) translated into a php aray. My form contains below fields:

City - Text
IN - Text/Date
OUT - Text/Date
Rooms - Select ( 1->5 )
Adults - Select ( 1->5 )
Childs - Select ( 0->5 )

The php array that i need to receive is

Example If Rooms is - 1 and Adults - 2 the response must be:
$rooms[] = array(array("paxType" => "Adult"), array("paxType" => "Adult")); 

Example If Rooms is - 2 and Adults - 3 the response must be:
$rooms[] = array(array("paxType" => "Adult"), array("paxType" => "Adult")); 
$rooms[] = array(array("paxType" => "Adult")); 

I am using the below code

$Adults = intval($_POST["Adults"]);
$rooms = array();
for ($x = 0; $x < $Adults; $x++) {
    array_push($rooms,array("paxType" => "Adult"));
}

but i am receive onbly the response with 1 room and 1 adult.

Razvan Baba
  • 155
  • 9
  • This makes no sense at all. An HTML form won't send JSON (although you could manually build a JSON request using JavaScript) and a JSON request wouldn't be a SOAP request. They are completely different formats. – Quentin Dec 29 '14 at 09:35
  • You appear to have asked the same question three times now. Each time with less detail then the previous. [1](http://stackoverflow.com/questions/27669265/translate-html-form-request-to-php-array) [2](http://stackoverflow.com/questions/27675114/can-i-send-soap-request-from-html-form) [3](http://stackoverflow.com/questions/27686210/how-to-send-json-request-from-html-form-and-receive-in-soap) – Quentin Dec 29 '14 at 09:37
  • Possible duplicate of [Translate HTML form request to php array](http://stackoverflow.com/questions/27669265/translate-html-form-request-to-php-array) – Quentin Dec 29 '14 at 09:39
  • Sorry for that, i am struggling with this for several days.. We learn from mistakes and StackOverflow :) – Razvan Baba Dec 29 '14 at 09:48

1 Answers1

1

It is easy to do this, even with plain HTML Form Submit ( can be done with JSON XHR request too)

I assume that your SELECT HTML form element name is "adultCount"

$adultCount = intval($_GET["adultCount"]);
$rooms = array();
for ($x = 0; $x < $adultCount; $x++) {
    array_push($rooms,array("paxType" => "Adult"));
} 

FYI, We don't use SOAP for web pages, even though it can be done ( it is unnecessary).

Pratap Koritala
  • 1,557
  • 14
  • 16