मैं "Check"
की तरह एक ही attr name
के साथ एक बहु चेकबॉक्स है, लेकिन हर चेकबॉक्स अलग मूल्यएक ही नाम
है तो मैं एक jQuery कोड है कि अगर मैं पर प्रेस बनाने के लिए के साथ बहु चेकबॉक्स से मान प्राप्त करने के लिए कैसे चेकबॉक्स इस कोड
$(document).ready(function(){
var NewsPaperId;
var UserId;
var CategoryId;
$("input[type='checkbox']").click(function() {
if ($(this).is(':checked')) {
NewsPaperId= $('input[name="Check"]:checked').val();
UserId= $(".userId").val();
CategoryId= $(".CategoryId").val();
alert(NewsPaperId);
$.post("AddAndDelete.php",
{
Add:1,
UserId: UserId,
NewsPaperId: NewsPaperId,
CategoryId:CategoryId
},
function(data, status){
alert("Data: " + data + "\nStatus: " + status);
});
} else {
NewsPaperId= $('input[name="Check"]:checked').val();
UserId= $(".userId").val();
CategoryId= $(".CategoryId").val();
alert(NewsPaperId);
$.post("AddAndDelete.php",
{
Delete:1,
UserId: UserId,
NewsPaperId: NewsPaperId,
CategoryId:CategoryId
},
function(data, status){
alert("Data: " + data + "\nStatus: " + status);
});
}
});
});
और यहाँ चेकबॉक्स कोड
<?php
$i=1;
$sql = "SELECT NewsPaperStatus.*,UserChoises.*"
. " FROM NewsPaperStatus"
. " LEFT JOIN UserChoises"
. " ON NewsPaperStatus.Id=UserChoises.NewsPaperId"
. " WHERE NewsPaperStatus.CategoryId=$Categoryid";
$query = mysql_query($sql);
while ($row = mysql_fetch_assoc($query)){
if($i==1){
if($row['Id']==$row['NewsPaperId']){
echo '<tr><th><img src="../images/NewsPaper/'.$row['Logo'].'"/></th><th><a href="">'.$row['Name'].'</a></th><th><input class="check" type="checkbox" checked="checked" name="Check" value="'.$row['Id'].'"/></th>';
}else{
echo '<tr><th><img src="../images/NewsPaper/'.$row['Logo'].'"/></th><th><a href="">'.$row['Name'].'</a></th><th><input class="check" type="checkbox" name="Check" value="'.$row['Id'].'"/></th>';
}
}
else if($i==2){
if($row['NewsPaperId']==$row['Id']){
echo '<th><img src="../images/NewsPaper/'.$row['Logo'].'"/></th><th><a href="">'.$row['Name'].'</a></th><th><input class="check" type="checkbox" checked="checked" name="Check" value="'.$row['Id'].'"/></th>';
}else{
echo '<th><img src="../images/NewsPaper/'.$row['Logo'].'"/></th><th><a href="">'.$row['Name'].'</a></th><th><input class="check" type="checkbox" name="Check" value="'.$row['Id'].'"/></th>';
}
}
else if($i==3){
if($row['NewsPaperId']==$row['Id']){
echo '<th><img src="../images/NewsPaper/'.$row['Logo'].'"/></th><th><a href="">'.$row['Name'].'</a></th><th><input class="check" type="checkbox" checked="checked" name="Check" value="'.$row['Id'].'"/></th></tr>';
}else{
echo '<th><img src="../images/NewsPaper/'.$row['Logo'].'"/></th><th><a href="">'.$row['Name'].'</a></th><th><input class="check" type="checkbox" name="Check" value="'.$row['Id'].'"/></th></tr>';
}
$i=0;
}
$i++;
}
?>
तो php द्वारा बनाई गई है जैसे php में कुछ काम करेंगे समस्या तब होती है जब मैं किसी भी चेक बॉक्स पर अपने काम को दबाता हूं लेकिन जब मैंने इसे दूसरे पर अनचेक किया तो चेक बॉक्स का आखिरी घाटा लें ((यदि मैं चेकबॉक्स मान 16 पर दबाता हूं और चेकबॉक्स मान 17 पर दबाता हूं तो यह अच्छा काम करता है लेकिन जब मैं चाहता हूं मान 16 के चेकबॉक्स को अनचेक करें 17 यह मान 17 है जो चेकबॉक्स का अंतिम मान लेता है I चेक किया गया था।
आप जो प्राप्त करना चाहते हैं उस पर इतना स्पष्ट नहीं है और आपको परेशानी कहां है। – Lupin