Is there a way to get the form name in my jsp?
In this case, you can use document.forms to reference it if this is the first form in your page (index 1 for second, 2 for thrid etc.).
I have a print button on my Jsp page which invokes the print option.
My problem is... I have written a fun printScreen()
in which i am invoking window.print()..the next line is submitting the form calling "somePage.do".
When I click the print button....it invokes the print dialog box and then submits the form which returns the next Jsp page.
What I want is when Print is invoked I dont want to submit the form unless user has decided to print (Whether Ok or cancel). I only want to submit the form when User clicks Ok/Cancel button of the print dialog box.
Is it possible to do that? Does window.print() returns any value ? By using that return value i can write if-else to submit the for....
Please let me know if you guys have any clue.
Thanks in advance.
There is several ways :
1. If you know the sequence of the form object in the page, for example your form is always the first form, use :
document.forms..... and for second form : document.forms..... and so on.
Var hiddenValue = document.getElementById("hiddenId").value;
where hiddenId is the Id attribute of the hidden field.