“打印”复选框 仅所选数据



嗨,我有结果,它包含一个复选框作为<input type='checkbox' name="ChkS[]" value='<? echo $rs->id?>'>

我在页脚中有一个打印列表选项作为<input type="button" value="Show Printable List" class="butten" onClick="openPrint()">

它在新的弹出窗口中打开可打印列表。

function openPrint() {
    window.open("<?= $_SERVER["PHP_SELF"]; ?>?<?=$qstring?>&print=true","","width=1024,height=600,menubar=yes,resizable=yes, scrollbars=yes");
}

我需要使用上面的选择复选框,它应该在弹出窗口中显示选定的打印列表?

我希望理解它应该不是问题1。有什么帮助吗?

Javascript 修改:

var s = "";
function changeval(value) {
    s = value;
}
function openPrint() {
    alert(s);
    window.open("<?= $_SERVER["PHP_SELF"]; ?>?<?=$qstring?>&print=true","","width=1024,height=600,menubar=yes,resizable=yes, scrollbars=yes");
}

网页修改:

<input type='checkbox' name="ChkS[]" value='<? echo $rs->id?>' onchange="changeval(this.value)" />

我做了什么?

  1. 创建了一个全局变量s

  2. 附加或绑定onchange事件于复选框,并根据设置变量s的值。

  3. 现在,您有带有值的可变s,您只需在任何函数中使用它。

目前您已经定义了按钮点击事件,而不是在复选框。

<input type='checkbox' name="ChkS[]" value='<? echo $rs->id?>' onClick="openPrint();">

希望这能帮助您解决问题。

最新更新