如何将此优惠券打印到A4尺寸的纸张上?

时间:2017-01-05 06:20:21

标签: javascript css printing

<script>
function myFunction() {


window.print();
}
</script>
<form >
<input type="submit" value="Submit">
</form>

但我只需要打印Just My table Tr

1 个答案:

答案 0 :(得分:0)

从这里选择代码Print a div content using Jquery

<html>
<body>
    <form name="mainForm">
        <select id="mainSelect" name="mainSelect"></select>
    </form>
</body>
<script>
function putDropDown(dataArr, fnVars){
    var dropField = document.forms[fnVars['formName']].elements[fnVars['fieldName']];
    if (dropField) {
        dropField.options.length = 0;
        if (dataArr != 'empty') {
            for (var i in dataArr[fnVars['valFld']]) {
                var groupData = dataArr[fnVars['valFld']][i];
                var group = document.createElement('optgroup');
                group.label = groupData.group;
                for (var key in groupData.options) {
                    var opt = document.createElement('option');
                    opt.value = key;
                    opt.innerHTML = groupData.options[key];
                    group.appendChild(opt);
                }
                dropField.appendChild(group);
            }
        }
    }
}
putDropDown(
    {mSelect: [
        {group: 'top', options: {1: 'one', 2: 'two'}},
        {group: 'bottom', options: {f: 'foo', b: 'bar'}}
    ]},
    {formName: 'mainForm', fieldName: 'mainSelect', valFld: 'mSelect'}
);
</script>
</html>