Форум программистов, компьютерный форум, киберфорум
PHP для начинающих
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.83/6: Рейтинг темы: голосов - 6, средняя оценка - 4.83
3 / 3 / 2
Регистрация: 18.12.2015
Сообщений: 189

Select if else

12.04.2016, 09:34. Показов 1287. Ответов 7
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
Добрый день !

вообщем такая ситуация в гугле не нашел как правильно реализовать

как сделать скажем что-бы при выборе в селекте первой опции дальше перебрасовало на if
а при выборе второй на else
0
Programming
Эксперт
39485 / 9562 / 3019
Регистрация: 12.04.2006
Сообщений: 41,671
Блог
12.04.2016, 09:34
Ответы с готовыми решениями:

Как изменить значение одного select-а при изменении другого select-а?
Добрый день! Подскажите как изменить значение select при изменении другого select. первый: <select id="options"> ...

Как при изменении одного <select> подгрузить в другой <select> данные...
Как при изменении одного &lt;select&gt; подгрузить в другой &lt;select&gt; данные... пример: с марками машин. При выборе 'TOYOTA'...

Как отображать определенные данные в <select> в зависимости от значений в другом <select>?
Здравствуйте! У меня на страницу есть два &lt;select&gt;. В каждом из них располагаются даты в формате dd.mm.yyyy. &lt;select...

7
Эксперт PHP
3899 / 3237 / 1353
Регистрация: 01.08.2012
Сообщений: 10,909
12.04.2016, 09:39
Ну с такими формулировками вообще трудно что-то найти. Опишите нормально задачу, что значит "перебрасывало" и т.д.
0
3 / 3 / 2
Регистрация: 18.12.2015
Сообщений: 189
12.04.2016, 09:45  [ТС]
Jodah,
При выборе Paypal должно перебрасовать на форму с заполнением данными для paypal и так-же для Банковского счета. Я думаю правильно будет сделать через if else но как правильно это реализовать ?)
HTML5
1
<select><option value="">Paypal</option><option>Банковский счет</option></select>
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
    if ( $paypal_email == '' ) {
            
                $output .= '<div class="btTotalQuoteContactGroup">';
 
                    $output .= '<div class="btQuoteContact">';
                        $output .= '<div class="btQuoteItem' . $m_name . '"><input type="text" class="btContactName btContactField" placeholder="' . __( 'Name', 'bt_plugin' ) . '"></div>';
                        $output .= '<div class="btQuoteItem' . $m_email . '"><input type="text" class="btContactEmail btContactField" placeholder="' . __( 'Email', 'bt_plugin' ) . '"></div>';
                        $output .= '<div class="btQuoteItem' . $m_phone . '"><input type="text" class="btContactPhone btContactField" placeholder="' . __( 'Phone', 'bt_plugin' ) . '"></div>';
                        $output .= '<div class="btQuoteItem' . $m_phone . '"><input type="text" class="btContactAddress btContactField" placeholder="' . __( 'Address', 'bt_plugin' ) . '"></div>';
                        
                        if ( $show_booking != '' ) {
                            $output .= '<div class="btQuoteItem' . $m_date . '"><input type="text" class="btContactDate btContactField" placeholder="' . __( 'Preferred Service Date', 'bt_plugin' ) . '"></div>';
                            $output .= '<div class="btQuoteItem' . $m_time . '">';
                                $output .= '<div class="btContactTime btContactField btDropDown"></div>';
                                if ( $time_start == '' ) $time_start = 0;
                                if ( $time_end == '' ) $time_end = 23;
                                $proxy = new CostTime_Proxy( $time_start, $time_end, __( 'Preferred Service Time', 'bt_plugin' ), $css_class );
                                add_action( 'wp_footer', array( $proxy, 'js_init' ), 20 );
                            $output .= '</div>';
                        }
                        
                        $output .= '<div class="btQuoteItem' . $m_message . ' btQuoteItemFullWidth"><textarea class="btContactMessage btContactField" placeholder="' . __( 'Message', 'bt_plugin' ) . '"></textarea></div>';
                        
                        if ( $email_confirmation == 'yes' ) {
                            $output .= '<div class="bt_cc_email_confirmation_container"><input id="bt_cc_email_confirmation" type="checkbox" value="yes"><label for="bt_cc_email_confirmation">' . __( 'Email me quote!', 'bt_plugin' ) . '</label></div>';
                        }                       
                        
                        if ( $rec_site_key != '' && $rec_secret_key != '' ) {
                            wp_enqueue_script( 'bt_recaptcha', 'https://www.google.com/recaptcha/api.js' );
                            $output .= '<div class="g-recaptcha" data-sitekey="' . $rec_site_key . '"></div>';
                        }
                    $output .= '<div class="btPayPalButton" style="background-image:url(' . plugin_dir_url( __FILE__ ) . 'paypal.png);"></div><form class="btPayPalForm" action="https://www.paypal.com/cgi-bin/webscr" method="post">
                        <input type="hidden" name="cmd" value="_cart">
                        <input type="hidden" name="upload" value="1">
                        <input type="hidden" name="business" value="' . $paypal_email . '">
                        <input type="hidden" name="item_name" value="' . $paypal_cart_name . '">
                        <input type="hidden" name="currency_code" value="' . $paypal_currency . '">
                        <input type="image" src="' . plugin_dir_url( __FILE__ ) . 'paypal.png" name="submit" alt="PayPal">
                        </form><span> Оплата через Paypal</span>
                        ';                          
                        $output .= '<div class="boldBtn btnAccent btnSmall btnIco"><button type="submit" class="btContactSubmit">' . __( 'Submit', 'bt_plugin' ) . '</button>';
 
                        $output .= '<div class="btSubmitMessage"></div>';
                        
                    $output .= '</div>';
                
                $output .= '</div>';
        }
        else{
            $output .= '<div class="btTotalQuoteContactGroup">';
 
            $output .= '<div class="btQuoteContact">';
            $output .= '<div class="btQuoteItem' . $m_name . '"><input type="text" class="btContactName btContactField" placeholder="' . __( 'Name', 'bt_plugin' ) . '"></div>';
            $output .= '<div class="btQuoteItem' . $m_email . '"><input type="text" class="btContactEmail btContactField" placeholder="' . __( 'Email', 'bt_plugin' ) . '"></div>';
            $output .= '<div class="btQuoteItem' . $m_phone . '"><input type="text" class="btContactPhone btContactField" placeholder="' . __( 'Phone', 'bt_plugin' ) . '"></div>';
            $output .= '<div class="btQuoteItem' . $m_phone . '"><input type="text" class="btContactAddress btContactField" placeholder="' . __( 'Address', 'bt_plugin' ) . '"></div>';
 
            if ( $show_booking != '' ) {
                $output .= '<div class="btQuoteItem' . $m_date . '"><input type="text" class="btContactDate btContactField" placeholder="' . __( 'Preferred Service Date', 'bt_plugin' ) . '"></div>';
                $output .= '<div class="btQuoteItem' . $m_time . '">';
                $output .= '<div class="btContactTime btContactField btDropDown"></div>';
                if ( $time_start == '' ) $time_start = 0;
                if ( $time_end == '' ) $time_end = 23;
                $proxy = new CostTime_Proxy( $time_start, $time_end, __( 'Preferred Service Time', 'bt_plugin' ), $css_class );
                add_action( 'wp_footer', array( $proxy, 'js_init' ), 20 );
                $output .= '</div>';
            }
 
            $output .= '<div class="btQuoteItem' . $m_message . ' btQuoteItemFullWidth"><textarea class="btContactMessage btContactField" placeholder="' . __( 'Message', 'bt_plugin' ) . '"></textarea></div>';
 
            if ( $email_confirmation == 'yes' ) {
                $output .= '<div class="bt_cc_email_confirmation_container"><input id="bt_cc_email_confirmation" type="checkbox" value="yes"><label for="bt_cc_email_confirmation">' . __( 'Email me quote!', 'bt_plugin' ) . '</label></div>';
            }
 
            if ( $rec_site_key != '' && $rec_secret_key != '' ) {
                wp_enqueue_script( 'bt_recaptcha', 'https://www.google.com/recaptcha/api.js' );
                $output .= '<div class="g-recaptcha" data-sitekey="' . $rec_site_key . '"></div>';
            }
            $output .= '<div class="btPayPalButton" style="background-image:url(' . plugin_dir_url( __FILE__ ) . 'paypal.png);"></div><form class="btPayPalForm" action="https://www.paypal.com/cgi-bin/webscr" method="post">
                        <input type="hidden" name="cmd" value="_cart">
                        <input type="hidden" name="upload" value="1">
                        <input type="hidden" name="business" value="' . $paypal_email . '">
                        <input type="hidden" name="item_name" value="' . $paypal_cart_name . '">
                        <input type="hidden" name="currency_code" value="' . $paypal_currency . '">
                        <input type="image" src="' . plugin_dir_url( __FILE__ ) . 'paypal.png" name="submit" alt="PayPal">
                        </form><span> Оплата через Paypal</span>
                        ';
            $output .= '<div class="boldBtn btnAccent btnSmall btnIco"><button type="submit" class="btContactSubmit">' . __( 'Submit', 'bt_plugin' ) . '</button>';
 
            $output .= '<div class="btSubmitMessage"></div>';
 
            $output .= '</div>';
 
            $output .= '</div>';
        }
        $output .= '</div>';
        $output .= '</div>';
        
        return $output;
    }
0
 Аватар для 0xD61C90
15 / 15 / 13
Регистрация: 14.03.2016
Сообщений: 78
12.04.2016, 09:47
PHP
1
2
3
4
5
if ($_POST['select'] == '1'){...}else{...}
 
 
<option value="1"> if</option>
<option value="2">else</option>
0
3 / 3 / 2
Регистрация: 18.12.2015
Сообщений: 189
12.04.2016, 09:56  [ТС]
0xD61C90, не работает (
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
class bt_cost_calculator {
 
    static function init() {
        add_shortcode( 'bt_cost_calculator', array( __CLASS__, 'handle_shortcode' ) );
        add_action( 'wp_ajax_bt_cc', array( __CLASS__, 'bt_cc_callback' ) );
        add_action( 'wp_ajax_nopriv_bt_cc', array( __CLASS__, 'bt_cc_callback' ) );
    }
    
    static function bt_cc_callback() {
        $recaptcha_response = $_POST['recaptcha_response'];
        $recaptcha_secret = $_POST['recaptcha_secret'];
        $admin_email = $_POST['admin_email'];
        $email_client = $_POST['email_client'];
        $email_confirmation = $_POST['email_confirmation'];
        $subject = urldecode( $_POST['subject'] );
        $quote = urldecode( $_POST['quote'] );
        $total = $_POST['total'];
        $name = $_POST['name'];
        $email = strip_tags( $_POST['email'] );
        $phone = $_POST['phone'];
        $address = $_POST['address'];
        $date = isset($_POST['date'])?$_POST['date']:'';
        $time = isset($_POST['time'])?$_POST['time']:'';
        $message = $_POST['message'];
        $paypal_select = 1;
        $bank_select = 1;
        
        if ( $recaptcha_response != '' && $recaptcha_secret != '' ) {
            $recaptcha_post = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', array( 'body' => array( 'secret' => $recaptcha_secret, 'response' => $recaptcha_response ) ) );
            if ( is_wp_error( $recaptcha_post ) ) {
                echo 'recaptcha post error';
                die();
            } else {
                $json = json_decode( $recaptcha_post['body'] );
                if ( $json->success != 1 ) {
                    echo 'recaptcha response false';
                    die();
                }
            }
        }
        
        $message_to_admin = '<html><body>' . "\r\n";
        
        $message_to_admin .= '<table style="width:100%" cellspacing="0">' . "\r\n";
        if ( $quote != '' ) $message_to_admin .= $quote;
        $message_to_admin .= '<tr><td style="font-weight:bold;border-top:1px solid #888;padding:.5em;">' . __( 'Total', 'bt_plugin' ) . '</td><td style="text-align:right;font-weight:bold;border-top:1px solid #888;padding:.5em;">' . $total . '</td></tr>' . "\r\n";
        $message_to_admin .= '</table>' . "\r\n";
        
        $message_to_admin .= '<br>' . "\r\n";
    
        if ( $name != '' ) $message_to_admin .= '<div style="padding:.5em;"><b>' . __( 'Name', 'bt_plugin' ) . '</b>: ' . stripslashes( $name ) . '</div>' . "\r\n";
        if ( $email != '' ) $message_to_admin .= '<div style="padding:.5em;"><b>' . __( 'Email', 'bt_plugin' ) . '</b>: <a href="mailto:' . $email . '">' . $email . '</a></div>' . "\r\n";
        if ( $phone != '' ) $message_to_admin .= '<div style="padding:.5em;"><b>' . __( 'Phone', 'bt_plugin' ) . '</b>: ' . $phone . '</div>' . "\r\n";
        if ( $address != '' ) $message_to_admin .= '<div style="padding:.5em;"><b>' . __( 'Address', 'bt_plugin' ) . '</b>: ' . stripslashes( $address ) . '</div>' . "\r\n";
        if ( $date != '' ) $message_to_admin .= '<div style="padding:.5em;"><b>' . __( 'Service Date', 'bt_plugin' ) . '</b>: ' . $date . '</div>' . "\r\n";
        if ( $time != '' ) $message_to_admin .= '<div style="padding:.5em;"><b>' . __( 'Service Time', 'bt_plugin' ) . '</b>: ' . $time . '</div>' . "\r\n";
        if ( $message != '' ) $message_to_admin .= '<div style="padding:.5em;"><b>' . __( 'Message', 'bt_plugin' ) . '</b>: ' . stripslashes( $message ) . '</div>' . "\r\n";
        
        $message_to_admin .= '</body></html>';
        
        //$message_to_admin = quoted_printable_encode( $message_to_admin );
    
        $s = $subject;
        if ( $name != '' ) $s = $s . ' / ' . $name;
        
        try{
            $r = true;
            if ( $email_client == 'yes' && $email != '' &&  $email_confirmation == 'yes' ) {
                $headers = "From: " . $admin_email . "\r\n";
                $headers .= "MIME-Version: 1.0\r\n";
                $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
                //$headers .= "Content-Transfer-Encoding: quoted-printable";
                $r = wp_mail( $email, $s, $message_to_admin, $headers );
            }
            $headers = '';
            //if ( $email != '' ) $headers = "From: " . $email . "\r\n"; // todo: email validation
            $headers .= "MIME-Version: 1.0\r\n";
            $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
            //$headers .= "Content-Transfer-Encoding: quoted-printable";
            $r1 = wp_mail( $admin_email, $s, $message_to_admin, $headers );
            if ( $r && $r1 ) echo 'ok';
        } catch ( Exception $e ) {
            echo $e->getMessage();
        }
        
        die();
    }
 
    static function handle_shortcode( $atts, $content ) {
        extract( shortcode_atts( array(
            'admin_email'        => '',
            'subject'            => '',
            'email_client'       => '',
            'email_confirmation' => '',
            'time_start'         => '',
            'time_end'           => '',
            'currency'           => '',
            'm_name'             => '',
            'm_email'            => '',
            'm_phone'            => '',
            'm_address'          => '',
            'm_date'             => '',
            'm_time'             => '',
            'm_message'          => '',
            'accent_color'       => '',
            'show_booking'       => '',
            'rec_site_key'       => '',
            'rec_secret_key'     => '',
            'paypal_email'       => '',
            'paypal_cart_name'   => '',
            'paypal_currency'    => '',
            'el_class'           => '',
            'el_style'           => ''
        ), $atts, 'bt_cost_calculator' ) );
        
        $admin_email = sanitize_text_field( $admin_email );
        $subject = sanitize_text_field( $subject );
        $email_client = sanitize_text_field( $email_client );
        $email_confirmation = sanitize_text_field( $email_confirmation );
        $time_start = sanitize_text_field( $time_start );
        $time_end = sanitize_text_field( $time_end );
        $currency = sanitize_text_field( $currency );
        $m_name = sanitize_text_field( $m_name );
        $m_email = sanitize_text_field( $m_email );
        $m_phone = sanitize_text_field( $m_phone );
        $m_address = sanitize_text_field( $m_address );
        $m_date = sanitize_text_field( $m_date );
        $m_time = sanitize_text_field( $m_time );
        $m_message = sanitize_text_field( $m_message );
        $accent_color = sanitize_text_field( $accent_color );
        $show_booking = sanitize_text_field( $show_booking );
        $rec_site_key = sanitize_text_field( $rec_site_key );
        $rec_secret_key = sanitize_text_field( $rec_secret_key );
        $paypal_email = sanitize_text_field( $paypal_email );
        $paypal_cart_name = sanitize_text_field( $paypal_cart_name );
        $paypal_currency = sanitize_text_field( $paypal_currency );
        $el_class = sanitize_text_field( $el_class );
        $el_style = sanitize_text_field( $el_style );
        
        wp_enqueue_script( 'jquery-ui' );
        wp_enqueue_script( 'jquery-ui-datepicker' );
        
        wp_enqueue_script( 'jquery-ui-slider' );
        
        wp_enqueue_script( 'bt_touch-punch_js', plugins_url() . '/bt_cost_calculator/jquery.ui.touch-punch.min.js', array( 'jquery-ui-slider' ) );
        
        $css_class = uniqid( 'c' );
        
        $proxy = new Cost_Proxy( $admin_email, $email_client, $email_confirmation, $subject, $m_name, $m_email, $m_phone, $m_address, $m_message, $m_date, $m_time, $accent_color, $rec_secret_key, $css_class );
        add_action( 'wp_footer', array( $proxy, 'js_init' ), 20 );
        
        $style_attr = '';
        if ( $el_style != '' ) {
            $style_attr = 'style="' . $el_style . '"';
        }
        
        if ( $m_name != '' ) $m_name = ' ' . 'btContactField' . $m_name;
        if ( $m_email != '' ) $m_email = ' ' . 'btContactField' . $m_email;
        if ( $m_phone != '' ) $m_phone = ' ' . 'btContactField' . $m_phone;
        if ( $m_address != '' ) $m_address = ' ' . 'btContactField' . $m_address;
        if ( $m_message != '' ) $m_message = ' ' . 'btContactField' . $m_message;
        if ( $m_date != '' ) $m_date = ' ' . 'btContactField' . $m_date;
        if ( $m_time != '' ) $m_time = ' ' . 'btContactField' . $m_time;
        $output = '<div class="btQuoteBooking ' . $el_class . ' ' . $css_class . '" ' . $style_attr . '><div class="btQuoteBookingWrap">';
            $output .= '<div class="btQuoteBookingForm btActive">';
                $output .= wptexturize( do_shortcode( $content ) );
                $output .= '<div class="btTotalNextWrapper">';
                    $output .= '<div class="btQuoteTotal">Вы заказываете:<div class="boldBtn btnAccent btnSmall btnIco"></div>';
                    $output .= '<span class="btQuoteTotalText">' . __( 'Total', 'bt_plugin' ) . '</span><span class="btQuoteTotalCurrency">' . $currency . '</span><span class="btQuoteTotalCalc"></span></div>';
                    $output .= '<select><option value="1">Paypal</option><option value="2">Банковский счет</option></select>';
                        $output .= '<button type="submit" class="btContactNext">' . __( 'Next', 'bt_plugin' ) . '</button>';
 
                $output .= '</div>';
            $output .= '<hr></div>';        
            
    if ($_POST['select'] <= '1') {
            
                $output .= '<div class="btTotalQuoteContactGroup">';
 
                    $output .= '<div class="btQuoteContact">';
                        $output .= '<div class="btQuoteItem' . $m_name . '"><input type="text" class="btContactName btContactField" placeholder="' . __( 'Name', 'bt_plugin' ) . '"></div>';
                        $output .= '<div class="btQuoteItem' . $m_email . '"><input type="text" class="btContactEmail btContactField" placeholder="' . __( 'Email', 'bt_plugin' ) . '"></div>';
                        $output .= '<div class="btQuoteItem' . $m_phone . '"><input type="text" class="btContactPhone btContactField" placeholder="' . __( 'Phone', 'bt_plugin' ) . '"></div>';
                        $output .= '<div class="btQuoteItem' . $m_phone . '"><input type="text" class="btContactAddress btContactField" placeholder="' . __( 'Address', 'bt_plugin' ) . '"></div>';
                        
                        if ( $show_booking != '' ) {
                            $output .= '<div class="btQuoteItem' . $m_date . '"><input type="text" class="btContactDate btContactField" placeholder="' . __( 'Preferred Service Date', 'bt_plugin' ) . '"></div>';
                            $output .= '<div class="btQuoteItem' . $m_time . '">';
                                $output .= '<div class="btContactTime btContactField btDropDown"></div>';
                                if ( $time_start == '' ) $time_start = 0;
                                if ( $time_end == '' ) $time_end = 23;
                                $proxy = new CostTime_Proxy( $time_start, $time_end, __( 'Preferred Service Time', 'bt_plugin' ), $css_class );
                                add_action( 'wp_footer', array( $proxy, 'js_init' ), 20 );
                            $output .= '</div>';
                        }
                        
                        $output .= '<div class="btQuoteItem' . $m_message . ' btQuoteItemFullWidth"><textarea class="btContactMessage btContactField" placeholder="' . __( 'Message', 'bt_plugin' ) . '"></textarea></div>';
                        
                        if ( $email_confirmation == 'yes' ) {
                            $output .= '<div class="bt_cc_email_confirmation_container"><input id="bt_cc_email_confirmation" type="checkbox" value="yes"><label for="bt_cc_email_confirmation">' . __( 'Email me quote!', 'bt_plugin' ) . '</label></div>';
                        }                       
                        
                        if ( $rec_site_key != '' && $rec_secret_key != '' ) {
                            wp_enqueue_script( 'bt_recaptcha', 'https://www.google.com/recaptcha/api.js' );
                            $output .= '<div class="g-recaptcha" data-sitekey="' . $rec_site_key . '"></div>';
                        }
                    $output .= '<div class="btPayPalButton" style="background-image:url(' . plugin_dir_url( __FILE__ ) . 'paypal.png);"></div><form class="btPayPalForm" action="https://www.paypal.com/cgi-bin/webscr" method="post">
                        <input type="hidden" name="cmd" value="_cart">
                        <input type="hidden" name="upload" value="1">
                        <input type="hidden" name="business" value="' . $paypal_email . '">
                        <input type="hidden" name="item_name" value="' . $paypal_cart_name . '">
                        <input type="hidden" name="currency_code" value="' . $paypal_currency . '">
                        <input type="image" src="' . plugin_dir_url( __FILE__ ) . 'paypal.png" name="submit" alt="PayPal">
                        </form><span> Оплата через Paypal</span>
                        ';                          
                        $output .= '<div class="boldBtn btnAccent btnSmall btnIco"><button type="submit" class="btContactSubmit">' . __( 'Submit', 'bt_plugin' ) . '</button>';
 
                        $output .= '<div class="btSubmitMessage"></div>';
                        
                    $output .= '</div>';
                
                $output .= '</div>';
        }
        else{
            $output .= '<div class="btTotalQuoteContactGroup">';
 
            $output .= '<div class="btQuoteContact">';
 
            $output .= '<div class="btQuoteItem' . $m_email . '"><input type="text" class="btContactEmail btContactField" placeholder="' . __( 'Email', 'bt_plugin' ) . '"></div>';
            $output .= '<div class="btQuoteItem' . $m_phone . '"><input type="text" class="btContactPhone btContactField" placeholder="' . __( 'Phone', 'bt_plugin' ) . '"></div>';
            $output .= '<div class="btQuoteItem' . $m_phone . '"><input type="text" class="btContactAddress btContactField" placeholder="' . __( 'Address', 'bt_plugin' ) . '"></div>';
 
            if ( $show_booking != '' ) {
                $output .= '<div class="btQuoteItem' . $m_date . '"><input type="text" class="btContactDate btContactField" placeholder="' . __( 'Preferred Service Date', 'bt_plugin' ) . '"></div>';
                $output .= '<div class="btQuoteItem' . $m_time . '">';
                $output .= '<div class="btContactTime btContactField btDropDown"></div>';
                if ( $time_start == '' ) $time_start = 0;
                if ( $time_end == '' ) $time_end = 23;
                $proxy = new CostTime_Proxy( $time_start, $time_end, __( 'Preferred Service Time', 'bt_plugin' ), $css_class );
                add_action( 'wp_footer', array( $proxy, 'js_init' ), 20 );
                $output .= '</div>';
            }
 
            $output .= '<div class="btQuoteItem' . $m_message . ' btQuoteItemFullWidth"><textarea class="btContactMessage btContactField" placeholder="' . __( 'Message', 'bt_plugin' ) . '"></textarea></div>';
 
            if ( $email_confirmation == 'yes' ) {
                $output .= '<div class="bt_cc_email_confirmation_container"><input id="bt_cc_email_confirmation" type="checkbox" value="yes"><label for="bt_cc_email_confirmation">' . __( 'Email me quote!', 'bt_plugin' ) . '</label></div>';
            }
 
            if ( $rec_site_key != '' && $rec_secret_key != '' ) {
                wp_enqueue_script( 'bt_recaptcha', 'https://www.google.com/recaptcha/api.js' );
                $output .= '<div class="g-recaptcha" data-sitekey="' . $rec_site_key . '"></div>';
            }
            $output .= '<div class="btPayPalButton" style="background-image:url(' . plugin_dir_url( __FILE__ ) . 'paypal.png);"></div><form class="btPayPalForm" action="https://www.paypal.com/cgi-bin/webscr" method="post">
                        <input type="hidden" name="cmd" value="_cart">
                        <input type="hidden" name="upload" value="1">
                        <input type="hidden" name="business" value="' . $paypal_email . '">
                        <input type="hidden" name="item_name" value="' . $paypal_cart_name . '">
                        <input type="hidden" name="currency_code" value="' . $paypal_currency . '">
                        <input type="image" src="' . plugin_dir_url( __FILE__ ) . 'paypal.png" name="submit" alt="PayPal">
                        </form><span> Оплата через Paypal</span>
                        ';
            $output .= '<div class="boldBtn btnAccent btnSmall btnIco"><button type="submit" class="btContactSubmit">' . __( 'Submit', 'bt_plugin' ) . '</button>';
 
            $output .= '<div class="btSubmitMessage"></div>';
 
            $output .= '</div>';
 
            $output .= '</div>';
        }
        $output .= '</div>';
        $output .= '</div>';
        
        return $output;
    }
}
0
 Аватар для 0xD61C90
15 / 15 / 13
Регистрация: 14.03.2016
Сообщений: 78
12.04.2016, 10:02
В <select> добавьте $name;, $method,
а в if ($_POST['select'] замените select на $name

PHP
1
2
3
4
5
6
<select name="paypal" method="post">
<option1>
<option2>
</select>
 
$_POST['paypal']
0
3 / 3 / 2
Регистрация: 18.12.2015
Сообщений: 189
13.04.2016, 00:06  [ТС]
0xD61C90, честно говоря не понял немного как вы написали решение можете пожалуйста по другому что-ли )

Добавлено через 51 минуту
попытался сделать через switch но переходит на дефаулт всегда то есть условие неправильное но что конкретно не так не пойму
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
        $output = '<div class="btQuoteBooking ' . $el_class . ' ' . $css_class . '" ' . $style_attr . '><div class="btQuoteBookingWrap">';
            $output .= '<div class="btQuoteBookingForm btActive">';
                $output .= wptexturize( do_shortcode( $content ) );
                $output .= '<div class="btTotalNextWrapper">';
 
                    $output .= '<div class="btQuoteTotal">Вы заказываете:<div class="boldBtn btnAccent btnSmall btnIco"></div>';
                    $output .= '<span class="btQuoteTotalText">' . __( 'Total', 'bt_plugin' ) . '</span><span class="btQuoteTotalCurrency">' . $currency . '</span><span class="btQuoteTotalCalc"></span></div>';
                    $output .= '<button type="submit" class="btContactNext">' . __( 'Next', 'bt_plugin' ) . '</button>';
                    $output .= '<select name="pa" method="POST"><option value="1">Paypal</option><option value="2">Банковский счет</option></select>';
                    
                $output .= '</div>';
            $output .= '<hr></div>';
 
        switch($_POST['paypalka']){
            case '1':
 
                $output .= '<div class="btTotalQuoteContactGroup">';
 
                $output .= '<div class="btQuoteContact">';
                $output .= '<div class="btQuoteItem' . $m_name . '"><input type="text" class="btContactName btContactField" placeholder="' . __( 'Name', 'bt_plugin' ) . '"></div>';
                $output .= '<div class="btQuoteItem' . $m_email . '"><input type="text" class="btContactEmail btContactField" placeholder="' . __( 'Email', 'bt_plugin' ) . '"></div>';
                $output .= '<div class="btQuoteItem' . $m_phone . '"><input type="text" class="btContactPhone btContactField" placeholder="' . __( 'Phone', 'bt_plugin' ) . '"></div>';
                $output .= '<div class="btQuoteItem' . $m_phone . '"><input type="text" class="btContactAddress btContactField" placeholder="' . __( 'Address', 'bt_plugin' ) . '"></div>';
 
                if ( $show_booking != '' ) {
                    $output .= '<div class="btQuoteItem' . $m_date . '"><input type="text" class="btContactDate btContactField" placeholder="' . __( 'Preferred Service Date', 'bt_plugin' ) . '"></div>';
                    $output .= '<div class="btQuoteItem' . $m_time . '">';
                    $output .= '<div class="btContactTime btContactField btDropDown"></div>';
                    if ( $time_start == '' ) $time_start = 0;
                    if ( $time_end == '' ) $time_end = 23;
                    $proxy = new CostTime_Proxy( $time_start, $time_end, __( 'Preferred Service Time', 'bt_plugin' ), $css_class );
                    add_action( 'wp_footer', array( $proxy, 'js_init' ), 20 );
                    $output .= '</div>';
                }
 
                $output .= '<div class="btQuoteItem' . $m_message . ' btQuoteItemFullWidth"><textarea class="btContactMessage btContactField" placeholder="' . __( 'Message', 'bt_plugin' ) . '"></textarea></div>';
 
                if ( $email_confirmation == 'yes' ) {
                    $output .= '<div class="bt_cc_email_confirmation_container"><input id="bt_cc_email_confirmation" type="checkbox" value="yes"><label for="bt_cc_email_confirmation">' . __( 'Email me quote!', 'bt_plugin' ) . '</label></div>';
                }
 
                if ( $rec_site_key != '' && $rec_secret_key != '' ) {
                    wp_enqueue_script( 'bt_recaptcha', 'https://www.google.com/recaptcha/api.js' );
                    $output .= '<div class="g-recaptcha" data-sitekey="' . $rec_site_key . '"></div>';
                }
                $output .= '<div class="btPayPalButton" style="background-image:url(' . plugin_dir_url( __FILE__ ) . 'paypal.png);"></div><form class="btPayPalForm" action="https://www.paypal.com/cgi-bin/webscr" method="post">
                        <input type="hidden" name="cmd" value="_cart">
                        <input type="hidden" name="upload" value="1">
                        <input type="hidden" name="business" value="' . $paypal_email . '">
                        <input type="hidden" name="item_name" value="' . $paypal_cart_name . '">
                        <input type="hidden" name="currency_code" value="' . $paypal_currency . '">
                        <input type="image" src="' . plugin_dir_url( __FILE__ ) . 'paypal.png" name="submit" alt="PayPal">
                        </form><span> Оплата через Paypal</span>
                        ';
                $output .= '<div class="boldBtn btnAccent btnSmall btnIco"><button type="submit" class="btContactSubmit">' . __( 'Submit', 'bt_plugin' ) . '</button>';
 
                $output .= '<div class="btSubmitMessage"></div>';
 
                $output .= '</div>';
 
                $output .= '</div>';
                break;
            case '2':
                $output .= '<div class="btTotalQuoteContactGroup">';
 
                $output .= '<div class="btQuoteContact">';
 
                $output .= '<div class="btQuoteItem' . $m_email . '"><input type="text" class="btContactEmail btContactField" placeholder="' . __( 'Email', 'bt_plugin' ) . '"></div>';
                $output .= '<div class="btQuoteItem' . $m_phone . '"><input type="text" class="btContactPhone btContactField" placeholder="' . __( 'Phone', 'bt_plugin' ) . '"></div>';
                $output .= '<div class="btQuoteItem' . $m_phone . '"><input type="text" class="btContactAddress btContactField" placeholder="' . __( 'Address', 'bt_plugin' ) . '"></div>';
 
                if ( $show_booking != '' ) {
                    $output .= '<div class="btQuoteItem' . $m_date . '"><input type="text" class="btContactDate btContactField" placeholder="' . __( 'Preferred Service Date', 'bt_plugin' ) . '"></div>';
                    $output .= '<div class="btQuoteItem' . $m_time . '">';
                    $output .= '<div class="btContactTime btContactField btDropDown"></div>';
                    if ( $time_start == '' ) $time_start = 0;
                    if ( $time_end == '' ) $time_end = 23;
                    $proxy = new CostTime_Proxy( $time_start, $time_end, __( 'Preferred Service Time', 'bt_plugin' ), $css_class );
                    add_action( 'wp_footer', array( $proxy, 'js_init' ), 20 );
                    $output .= '</div>';
                }
 
                $output .= '<div class="btQuoteItem' . $m_message . ' btQuoteItemFullWidth"><textarea class="btContactMessage btContactField" placeholder="' . __( 'Message', 'bt_plugin' ) . '"></textarea></div>';
 
                if ( $email_confirmation == 'yes' ) {
                    $output .= '<div class="bt_cc_email_confirmation_container"><input id="bt_cc_email_confirmation" type="checkbox" value="yes"><label for="bt_cc_email_confirmation">' . __( 'Email me quote!', 'bt_plugin' ) . '</label></div>';
                }
 
                if ( $rec_site_key != '' && $rec_secret_key != '' ) {
                    wp_enqueue_script( 'bt_recaptcha', 'https://www.google.com/recaptcha/api.js' );
                    $output .= '<div class="g-recaptcha" data-sitekey="' . $rec_site_key . '"></div>';
                }
                $output .= '<div class="btPayPalButton" style="background-image:url(' . plugin_dir_url( __FILE__ ) . 'paypal.png);"></div><form class="btPayPalForm" action="https://www.paypal.com/cgi-bin/webscr" method="post">
                        <input type="hidden" name="cmd" value="_cart">
                        <input type="hidden" name="upload" value="1">
                        <input type="hidden" name="business" value="' . $paypal_email . '">
                        <input type="hidden" name="item_name" value="' . $paypal_cart_name . '">
                        <input type="hidden" name="currency_code" value="' . $paypal_currency . '">
                        <input type="image" src="' . plugin_dir_url( __FILE__ ) . 'paypal.png" name="submit" alt="PayPal">
                        </form><span> Оплата через Paypal</span>
                        ';
                $output .= '<div class="boldBtn btnAccent btnSmall btnIco"><button type="submit" class="btContactSubmit">' . __( 'Submit', 'bt_plugin' ) . '</button>';
 
                $output .= '<div class="btSubmitMessage"></div>';
 
                $output .= '</div>';
 
                $output .= '</div>';
                break;
            default:
                $output .= '<div class="btTotalQuoteContactGroup">';
 
                $output .= '<div class="btQuoteContact">';
 
                $output .= '<div class="btQuoteItem' . $m_email . '"><input type="text" class="btContactEmail btContactField" placeholder="' . __( 'Email', 'bt_plugin' ) . '"></div>';
 
 
                if ( $show_booking != '' ) {
                    $output .= '<div class="btQuoteItem' . $m_date . '"><input type="text" class="btContactDate btContactField" placeholder="' . __( 'Preferred Service Date', 'bt_plugin' ) . '"></div>';
                    $output .= '<div class="btQuoteItem' . $m_time . '">';
                    $output .= '<div class="btContactTime btContactField btDropDown"></div>';
                    if ( $time_start == '' ) $time_start = 0;
                    if ( $time_end == '' ) $time_end = 23;
                    $proxy = new CostTime_Proxy( $time_start, $time_end, __( 'Preferred Service Time', 'bt_plugin' ), $css_class );
                    add_action( 'wp_footer', array( $proxy, 'js_init' ), 20 );
                    $output .= '</div>';
                }
 
                $output .= '<div class="btQuoteItem' . $m_message . ' btQuoteItemFullWidth"><textarea class="btContactMessage btContactField" placeholder="' . __( 'Message', 'bt_plugin' ) . '"></textarea></div>';
 
                if ( $email_confirmation == 'yes' ) {
                    $output .= '<div class="bt_cc_email_confirmation_container"><input id="bt_cc_email_confirmation" type="checkbox" value="yes"><label for="bt_cc_email_confirmation">' . __( 'Email me quote!', 'bt_plugin' ) . '</label></div>';
                }
 
                if ( $rec_site_key != '' && $rec_secret_key != '' ) {
                    wp_enqueue_script( 'bt_recaptcha', 'https://www.google.com/recaptcha/api.js' );
                    $output .= '<div class="g-recaptcha" data-sitekey="' . $rec_site_key . '"></div>';
                }
                $output .= '<div class="btPayPalButton" style="background-image:url(' . plugin_dir_url( __FILE__ ) . 'paypal.png);"></div><form class="btPayPalForm" action="https://www.paypal.com/cgi-bin/webscr" method="post">
                        <input type="hidden" name="cmd" value="_cart">
                        <input type="hidden" name="upload" value="1">
                        <input type="hidden" name="business" value="' . $paypal_email . '">
                        <input type="hidden" name="item_name" value="' . $paypal_cart_name . '">
                        <input type="hidden" name="currency_code" value="' . $paypal_currency . '">
                        <input type="image" src="' . plugin_dir_url( __FILE__ ) . 'paypal.png" name="submit" alt="PayPal">
                        </form><span> Оплата через Paypal</span>
                        ';
                $output .= '<div class="boldBtn btnAccent btnSmall btnIco"><button type="submit" class="btContactSubmit">' . __( 'Submit', 'bt_plugin' ) . '</button>';
 
                $output .= '<div class="btSubmitMessage"></div>';
 
                $output .= '</div>';
 
                $output .= '</div>';
 
        }
        $output .= '</div>';
        $output .= '</div>';
        
        return $output;
0
 Аватар для 0xD61C90
15 / 15 / 13
Регистрация: 14.03.2016
Сообщений: 78
13.04.2016, 04:33
Да уж не знаю как проще объяснить..

PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
 
# PHP HANDLER
 
if ($_POST['select_paypal'] == 'paypal'){echo 'Вы выбрали оплату PayPal';}
if ($_POST['select_paypal'] == 'not_paypal'){echo 'Вы выбрали оплату Not PayPal';}
 
//если всего 2 значения можно использовать else {echo 'Вы выбрали оплату Not PayPal';}
 
# FORM HTML
 
echo '<form action="' . $_SERVER['SCRIPT_NAME'] . 'method="post">'
echo '<select name="select_paypal" method="post">';
echo '<option value="paypal">PayPal</option>';
echo '<option value="not_paypal">Not PayPal</option>';
echo '<select>';
echo '<input type="submit" value="Отправить">';
echo '</form>';
 
?>
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
inter-admin
Эксперт
29715 / 6470 / 2152
Регистрация: 06.03.2009
Сообщений: 28,500
Блог
13.04.2016, 04:33
Помогаю со студенческими работами здесь

Сохранение значения select и работоспособность второго select после отправки формы
Добрый вечер!Есть проблемка-не могу сохранить значение селекта,сохранив работоспособность др.селектов после отправки формы....страну...

Сохранение значения select и работоспособность второго select после отправки формы
Добрый вечер!Есть проблемка-не могу сохранить значение селекта,сохранив работоспособность др.селектов после отправки формы....страну...

Изменение данных одного select при изменении другого select
нужно что бы выбирая одну группу менялись данные в &quot;номере по журналу&quot; не понимаю как это сделать помогите &lt;?php ...

При выборе элемента в <select> менять содержимое другого <select>
Может кто-то подсказать. У меня есть select на форме. Например: &lt;select name=day_s size=1&gt; &lt;option value=1&gt; Понедельник &lt;/...

Вставка изображений в select и создание зависимости между соседним select
Добрый день! Есть вот такая конструкция: https://codepen.io/fromthemoon/pen/NVBLQj Необходимо, чтобы при выборе первого значения...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
8
Ответ Создать тему
Новые блоги и статьи
SDL3 для Web (WebAssembly): сборка C/C++ проекта из консоли
8Observer8 30.01.2026
Содержание блога Если вы откроете примеры для начинающих на официальном репозитории SDL3 в папке: examples, то вы увидите, что все примеры используют следующие четыре обязательные функции, а. . .
Установка Emscripten SDK (emsdk) и CMake на Windows для сборки C и C++ приложений в WebAssembly (Wasm)
8Observer8 30.01.2026
Чтобы скачать Emscripten SDK (emsdk) необходимо сначало скачать и уставить Git: Install for Windows. Следуйте стандартной процедуре установки Git через установщик. Система контроля версиями Git. . .
Подключение Box2D v3 к SDL3 для Android: физика и отрисовка коллайдеров
8Observer8 29.01.2026
Содержание блога Box2D - это библиотека для 2D физики для анимаций и игр. С её помощью можно определять были ли коллизии между конкретными объектами. Версия v3 была полностью переписана на Си, в. . .
Инструменты COM: Сохранение данный из VARIANT в файл и загрузка из файла в VARIANT
bedvit 28.01.2026
Сохранение базовых типов COM и массивов (одномерных или двухмерных) любой вложенности (деревья) в файл, с возможностью выбора алгоритмов сжатия и шифрования. Часть библиотеки BedvitCOM Использованы. . .
Загрузка PNG с альфа-каналом на SDL3 для Android: с помощью SDL_LoadPNG (без SDL3_image)
8Observer8 28.01.2026
Содержание блога SDL3 имеет собственные средства для загрузки и отображения PNG-файлов с альфа-каналом и базовой работы с ними. В этой инструкции используется функция SDL_LoadPNG(), которая. . .
Загрузка PNG с альфа-каналом на SDL3 для Android: с помощью SDL3_image
8Observer8 27.01.2026
Содержание блога SDL3_image - это библиотека для загрузки и работы с изображениями. Эта пошаговая инструкция покажет, как загрузить и вывести на экран смартфона картинку с альфа-каналом, то есть с. . .
Влияние грибов на сукцессию
anaschu 26.01.2026
Бифуркационные изменения массы гриба происходят тогда, когда мы уменьшаем массу компоста в 10 раз, а скорость прироста биомассы уменьшаем в три раза. Скорость прироста биомассы может уменьшаться за. . .
Воспроизведение звукового файла с помощью SDL3_mixer при касании экрана Android
8Observer8 26.01.2026
Содержание блога SDL3_mixer - это библиотека я для воспроизведения аудио. В отличие от инструкции по добавлению текста код по проигрыванию звука уже содержится в шаблоне примера. Нужно только. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru