我需要一个表单,如果选中表单中的复选框,则将类应用于 div,然后使用提交按钮打印页面
设置是当用户到达页面时,他们的信息将出现在他们放入先前表单中以供查看的页面上。该页面上还有一个表格,其中列出了 3 个选项,每个选项旁边都有一个复选框,表格底部有一个显示“打印”的按钮。
用户正在查看的页面顶部的信息也适用于隐藏在 div 中的 3 个字母。每个复选框代表一个隐藏字母,例如 letter1、letter2 和 letter3。
因此,我需要一个表单,其中 3 个字母中的每一个都有一个复选框,一个在单击时打印整个页面的提交按钮,以及当单击打印按钮时将类应用于每个选定字母的 div 的表单,因此 print.css 将仅打印应用了此类的 div。我更希望使用 javascript 或 jquery 完成这一切,但实际上任何简单的方法都是受欢迎的。
感谢所有的帮助!
<form action="" id="letterPrint">
<input type="checkbox" name="letter1" value="letter1" /> Letter 1
<input type="checkbox" name="letter2" value="letter2" /> Letter 2
<input type="checkbox" name="letter3" value="letter3" /> Letter 3
<input type="submit" value="print" />
</form>
这是我到目前为止的形式。
The set up is when the user arrives on the page, it will have their information on the page they put in a previous form to review. Also on the page will be a form with 3 options listed with a checkbox by each option, and a button at the bottom of the form that says "Print."
The information at the top of the page that the user is reviewing is also applied to 3 letters that are wrapped in divs with display hidden. Each checkbox represents one of the hidden letters, let's say letter1, letter2 and letter3.
So, I need a form that will have a checkbox for each of the 3 letters, a submit button that prints the entire page upon clicking, and for the form to apply a class to each of the selected letter's div when the print button is clicked, so the print.css will only print the divs that have this class applied to it. I'd preferably like all this done using javascript or jquery, but really any simple method is welcome.
Thank you to all that help!
<form action="" id="letterPrint">
<input type="checkbox" name="letter1" value="letter1" /> Letter 1
<input type="checkbox" name="letter2" value="letter2" /> Letter 2
<input type="checkbox" name="letter3" value="letter3" /> Letter 3
<input type="submit" value="print" />
</form>
This is my form thus far.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是您要找的吗?
Is this kind of what you're looking for?
首先,添加打印样式表不需要特定 div 的类。下面的代码使得当您的页面打印时,它会获取您的打印 CSS 并将其应用到页面,然后再发送打印。
使其自动打印比看起来更棘手。但是,您可以使用此代码调出打印框
将页面直接发送到打印机进行打印是不可能的,因为将数据发送到打印机所需的打印信息位于操作系统上。 JavaScript 仅与浏览器交互。
First, adding a print style sheet does not need a class to specific divs. The following code makes it so that when your page prints it will take your print css and apply it to the page before it gets sent off to print.
Making it print automatically is more tricky than it would seem. But, you can use this code to bring up the print box
Sending a page directly to the printer to be printed is not possible because the print information required to send data to the printer is located on the operating system. JavaScript only interacts with the browser.