[英]jQuery selector not showing the selected value of checkbox after click on submit button and i am getting error[object Object]
Hi i have small project in which i have tab 1 ie FahrzeugeWidget and tab 2 ie FahrzeugeWidgetEdit. 嗨,我有一个小项目,在其中我有选项卡1即FahrzeugeWidget和选项卡2即FahrzeugeWidgetEdit。 In 1 tab i have list and in second tab i have checkbox list from which i want to select what users want and then then switch to tab1 after submit button and show only values selected from checkbox.I used jQuery selector for same.Every thing is running fine.
在第一个选项卡中,我有列表,在第二个选项卡中,我有复选框列表,我想从中选择用户想要的内容,然后在提交按钮后切换到tab1并仅显示从复选框中选择的值。运行良好。 Only i am not able to get the values selected from checkbox after submit button.There is only small mistake i as doing not able to identify.Here is fiddle: demo So i should only get those values selected from checkbox.
提交按钮后,只有我无法从复选框中获取选择的值。只有一个小错误,我无法识别。这里是小提琴: 演示所以我应该只从复选框中获取那些值。 Here is my code:
这是我的代码:
dashboard.php dashboard.php
if($param['aktion'] == 'save-widget-vehicle')
{
$page['register-fahrzeuge'] = array(
1 => array( 'Fahrzeug','aktiv',$page['script'],''),
0 => array( 'Edit-Fahrzeug','enabled',$page['script'],'',''),
);
$opts = !empty($param['filterOpts']) ? $param['filterOpts'] : array();
$tmp = array();
foreach ($opts as $opt) {
$tmp[] = '"'.$opt.'"';
}
$query =
'SELECT Fahrzeuge.dsnr,name
FROM Fahrzeuge
INNER JOIN ohne_fahrzeuge ON Fahrzeuge.dsnr = ohne_fahrzeuge.dsnr
WHERE Fahrzeuge.name IN ('.implode(",", $tmp).')';
$result = mysql_query($query, $myConnection);
$data = array();
$html = '<table width="538" cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<div>'.CreateRegister($page['register-news']).'</div>
'.CreateMessage().'
<div class="cont-liste-verlauf register"> ';
while($row = mysql_fetch_array($result)){
//$news_result = $fahrzeuge['name'];
$html .= '<table id="fahrzeuge">
<tr>
<td>
<a href="amo_fahrzeuge.php"> '. $data[] = $row .'</a>
</td>
</tr> ';
}
$html .= '</table>
</div>
</td>
</tr>
</table>';
$return = array(
'status' => 1,
'html' => $html
);
echo json_encode($return);
die();
$param['aktion'] = 'get-widget-vehicle';
}
dashboard.js dashboard.js
function getFahrzeuge() {
var opts = [];
$("input[type=checkbox]").each(function () {
if (this.checked) {
opts.push($(this).attr("id"));
}
});
return opts;
}
function saveFahrzeugeWidget(opts){
if(!opts || !opts.length){
opts = allFahrzeuge;
}
$.ajax({
type: "POST",
url: "ajax/dashboard.php",
dataType : 'json',
cache: false,
data: {filterOpts: opts, 'aktion' : 'save-widget-vehicle'},
success: function(data){
// $('#fahrzeuge').html(makeTable(records));
$('#fahrzeuge').html(data.html);
},
error: function(data){
alert('error' + data);
}
});
}
$('#fahrzeuge .butt-rahmen').live('click', function(){
if($(this).attr('id') == 'submitId')
var opts = getFahrzeuge();
saveFahrzeugeWidget(opts);
// $("#regl1").show();
// $("#regl1").hide();
});
var allFahrzeuge = [];
$("input[type=checkbox]").each(function(){
allFahrzeuge.push($(this)[0].id)
})
I don't know if this solves your problem but which JQuery version are you using? 我不知道这是否可以解决您的问题,但是您使用的是哪个JQuery版本? The JQuery function
.live()
is depricated since version 1.9. 从1.9版开始,就不再使用JQuery函数
.live()
。 You must use .on()
instead. 您必须改为使用
.on()
。 May you don't get the values because the action isn't triggered by the use of the live()
function? 您是否可能因为操作未通过使用
live()
函数而触发而无法获得这些值?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.