Home>

works perfectly without multiple, tell me how to make it so that it would be possible to transmit $ _Post ["Option '] by commas. Thank you!

<
SELECT NAME= "USERT []" Multiple ONCHANGE= "Fetch_Select (this.Value);" >
≪
optional= "0" &​​gt;
0 <
/Option >
≪
Option value= "1" >
1 <
/Option >
≪
Option value= "2" >
2 <
/Option >
≪
/SELECT >
≪
P id= "Print-Ajax" >
≪
/P >
≪
Script Type= "Text /JavaScript" >
            FUNCTION FETCH_SELECT (VAL) {
                $.ajax ({
                    Type: 'Post',
                    URL: './ajax/select_infor.php',
                    Datatype: 'Json',
                    Data: {Option: Val},
                    SUCCESS: FUNCTION (RESPONSE) {
                        $ ('# Print-ajax'). HTML (Response); //This Will Print You Result
  }
                });
            }
        ≪
/script >

select_infor.php:

echo $ _post ['option'];

Transmit to the server? What for? In the form of an array more convenient

mepihindeveloper2021-08-02 07:24:17
  • Answer # 1

    You do not work this code with MultiPle Since in this case an array is transmitted, not a scalar value. To check the value $ _Post ['usert'] Use the function VAR_DUMP () . To display the value of this variable, use the cycle Foreach. .

    $ Options=! Empty ($ _ post ['usert'])? $ _Post ['usert']: array ();
    Foreach ($ Options AS $ Option) {
        Echo $ Option;
    }
    

    Is it easy to use implode?

    mepihindeveloper2021-08-02 07:24:41

    @Mepihindeveloper, you can use anything. I do not know the level of knowledge of the author and the task he decides, so I wrote a basic example.

    VenZell2021-08-02 07:28:36

    Not the best "basic" moments. It is better to immediately advise using language functions

    mepihindeveloper2021-08-02 07:30:05

    @Mepihindeveloper, this is the most basic language functions. In the template you will also display a value through implode? I propose to finish the discussion. If you do not like the answer, you can write your own and vote for my.

    VenZell2021-08-02 07:31:19

    I visited foreach. Invalid Argument Supplied for Foreach (). In general, I xs -my level of knowledge, and the task is the only one, pass through the comma if several variables are selected. Therefore, asked with the code that is.

    Виктор Муравьев2021-08-02 07:53:04
  • Answer # 2

    You do not work this code with MultiPle Since in this case an array is transmitted, not a scalar value. To check the value $ _Post ['usert'] Use the function VAR_DUMP () . To display the value of this variable, use the cycle Foreach. .

    $ Options=! Empty ($ _ post ['usert'])? $ _Post ['usert']: array ();
    Foreach ($ Options AS $ Option) {
        Echo $ Option;
    }
    

    Is it easy to use implode?

    mepihindeveloper2021-08-02 07:24:41

    @Mepihindeveloper, you can use anything. I do not know the level of knowledge of the author and the task he decides, so I wrote a basic example.

    VenZell2021-08-02 07:28:36

    Not the best "basic" moments. It is better to immediately advise using language functions

    mepihindeveloper2021-08-02 07:30:05

    @Mepihindeveloper, this is the most basic language functions. In the template you will also display a value through implode? I propose to finish the discussion. If you do not like the answer, you can write your own and vote for my.

    VenZell2021-08-02 07:31:19

    I visited foreach. Invalid Argument Supplied for Foreach (). In general, I xs -my level of knowledge, and the task is the only one, pass through the comma if several variables are selected. Therefore, asked with the code that is.

    Виктор Муравьев2021-08-02 07:53:04