Javascript 如何从JS或Mootools中的表单获取数组以将其发送到PHP?
HTML:Javascript 如何从JS或Mootools中的表单获取数组以将其发送到PHP?,javascript,php,json,mootools,Javascript,Php,Json,Mootools,HTML: 如何从JS或Mootools中的表单获取数组以将其发送到PHP?将以JSON格式向PHP发送数据。问题在于选择器。您给出的是部分的名称,但使用的语法要求完整的名称 因此,请尝试以下方法: var birthdate = $contactForm.getElement('select[name^="birthdate"]').getProperty('value'); $$('select[name^=birthdate]') 但是,这只会得到第一个匹配的元素 因此,使用MooTo
如何从JS或Mootools中的表单获取数组以将其发送到PHP?将以JSON格式向PHP发送数据。问题在于选择器。您给出的是部分的
名称
,但使用的语法要求完整的名称
因此,请尝试以下方法:
var birthdate = $contactForm.getElement('select[name^="birthdate"]').getProperty('value');
$$('select[name^=birthdate]')
但是,这只会得到第一个匹配的元素
因此,使用MooTools,您可以执行以下操作:
var birthdate = $contactForm.getElement('select[name^="birthdate"]').getProperty('value');
$$('select[name^=birthdate]')
或在JS中:
document.querySelectorAll('select[name^=birthdate]')
希望这有助于可能重复@copeg need mootools您想要该
select
element`的选定值还是包含表单所选全部选定值的数组?