Code:
function open_win()
{
var x=document.getElementById('1').value;
var y=document.getElementById('2').value;
var mywin=window.open("http://hpcl-4kgt5pwd85/hr/Lists/FormVclr/print.htm");
mywin.document.write(x);
mywin.document.write(y);
mywin.document.close();
}
Note: The HTML spec requires that id's begin with a letter or an underscore, not a number. In most cases browsers will let you get away with using a a number though. The fact that you got:
[object HTMLInputElement]
means the element is being retrieved. But you don't want the entire element. I'm not 100% certain what you want from it, but it's very likely you want it's value as I have added to the code.
Some browsers will require that you close the document after writing to it. This will not close the window. It simply allows the document to signal to the browser that it has finished loading.
Using document.write() like that will likely overwrite the contents of print.htm. If your intention is to add to print.htm, rather than replace it with new content, a different approach may be required.
And if you want to replace it, it need not be listed at all:
Code:
function open_win()
{
var x=document.getElementById('1').value;
var y=document.getElementById('2').value;
var mywin=window.open("");
mywin.document.write(x);
mywin.document.write(y);
mywin.document.close();
}
Bookmarks