Форма Javascript отправляет действие изменения с атрибутами attrJquery

Программирование на jquery
Ответить
Anonymous
 Форма Javascript отправляет действие изменения с атрибутами attr

Сообщение Anonymous »

Я хочу изменить действие атрибута моей формы в цели, чтобы динамически получать следующую страницу. В javascript моя переменная action получает правильное значение, но страница все равно не загружается. Он отлично работает, если я вручную возвращаю правильное «значение», но не работает, когда я использую jQuery('#select_program').children().filter(':selected').text().replace(/\s+ /g, '-').toLowerCase(),, чтобы сделать это динамически.

Вот моя форма (на php):

Код: Выделить всё

public function form_creation() {
$html = '';
$html .= '';
$html .= '';
$html .= __('Language', 'mon-plugin');
$html .= '';
$html .= '';
$html .= '';
$html .= '';
$html .= __('Program', 'mon-plugin');
$html .= '';
$html .= '';
$html .= '';
$html .= '';
$html .= __('Country', 'mon-plugin');
$html .= '';
$html .= '';
$html .= '';
$html .= '';
$html .= __('City', 'mon-plugin');
$html .= '';
$html .= '';
$html .= '[i]        $html .= htmlspecialchars(json_encode($this->backend_select_category));
$html .= '"/>';
$html .= '';
$html .= '[/i]';
$html .= __('Search', 'mon-plugin');
$html .= '';
$html .= '';

return $html;
}
Вот мой JavaScript:

Код: Выделить всё

jQuery('#search_projects').submit(function() {
var selection_value = [
jQuery('#select_langue').val(),
jQuery('#select_program').val(),
jQuery('#select_country').val(),
jQuery('#select_city').val()
];
var selection_display = [
jQuery('#select_langue').children().filter(':selected').text().replace(/\s+/g, '-').toLowerCase(),
jQuery('#select_program').children().filter(':selected').text().replace(/\s+/g, '-').toLowerCase(),
jQuery('#select_country').children().filter(':selected').text().replace(/\s+/g, '-').toLowerCase(),
jQuery('#select_city').children().filter(':selected').text().replace(/\s+/g, '-').toLowerCase()
];
jQuery(this).attr('action', function() {
if (selection_value[1] !== 'nd') {
var action = selection_display[1];
if (selection_value[2] !== 'nd') {
action += selection_display[2];
if (selection_value[3] !== 'nd') {
action += selection_display[3];
}
}
} else {
var action = 'search_program';
}
return action;
});
});
Спасибо за помощь!

Подробнее здесь: https://stackoverflow.com/questions/463 ... attributes
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Jquery»