我正在尝试创建块ui的300个唯一实例
到目前为止,这就是我所拥有的,但它不起作用:
的javascript
<script type="text/javascript">
var i=0;
for (i=0;i<=300;i++) {
$(document).ready(function() {
$("#q" + i).click(function() {
$.blockUI({ message: $("#t" + i), css: { width: '1024px' } });
});
$('#yes').click(function() {
// update the block message
$.blockUI({ message: "<h1>Remote call in progress...</h1>" });
$.ajax({
url: 'wait.php',
cache: false,
complete: function() {
// unblock when remote call returns
$.unblockUI();
}
});
});
$('#no').click(function() {
$.unblockUI();
return false;
});
});
}
</script>
模态窗口
<?php do { ?>
<div id="q<?php echo $row_dd31['dNo']; ?>" style="display:none; cursor: default">
<h3>Driver <?php echo $row_dd31['dNo']; ?></h3><p>
<input type="button" id="yes" value="Save" style="width: 75px; height: 50px;"/> <input type="button" id="no" value="Exit" style="width: 75px; height: 50px;"/>
</div>
<?php } while ($row_dd31 = mysql_fetch_assoc($dd31)); ?>
单元格激活模态窗口
<tr height="100px" align="center">
<?php do { ?>
<td style="background-color: <?php echo $row_dd1['colour']; ?>;">
<input type="hidden" id="<?php echo $row_dd1['dNo']; ?>">
<button type="submit" class="link" id="t<?php echo $row_dd1['dNo']; ?>"><span><?php echo $row_dd1['dNo']; ?></span></button>
</td>
<?php } while ($row_dd1 = mysql_fetch_assoc($dd1)); ?>
</tr>
答案 0 :(得分:2)
将循环放在$(文件).ready
中
比如,
$(document).ready(function() {
var i=0;
for (i=0;i<=300;i++) {