Hi,
I am doing a lot of javascript on the client side while using struts on the server side.
My problem is that I cannot use "document.form.component....." in my javascript because the form name comes from the <form-bean name="FormName"> tag in the struts config.
Is there a way to get the form name in my jsp?
Thanks,
Sandeep Tiwary
-
javascript with struts (5 messages)
- Posted by: sandeep Tiwary
- Posted on: April 25 2003 12:48 EDT
Threaded Messages (5)
- Re: javascript with struts by Alan Choy on April 25 2003 13:03 EDT
- Re: javascript with struts by sandeep Tiwary on April 25 2003 13:13 EDT
- Re: javascript with struts by Alan Choy on April 25 2003 01:30 EDT
- Re: javascript with struts by sandeep Tiwary on April 25 2003 13:13 EDT
- Javascript Print Button using struts frmaework by Abhishek Tripathi on March 01 2006 11:33 EST
- javascript with struts by Majid Kalkatechi on March 01 2006 15:14 EST
-
Re: javascript with struts[ Go to top ]
- Posted by: Alan Choy
- Posted on: April 25 2003 13:03 EDT
- in response to sandeep Tiwary
You can pass "this.form" as a parameter into the JavaScript function. This way you don't need to explicitly specify the form name. -
Re: javascript with struts[ Go to top ]
- Posted by: sandeep Tiwary
- Posted on: April 25 2003 13:13 EDT
- in response to Alan Choy
Thanks Alan, but I need to call my javascript in <body onLoad="function()"> so I dont have a reference to my form at this time. -
Re: javascript with struts[ Go to top ]
- Posted by: Alan Choy
- Posted on: April 25 2003 13:30 EDT
- in response to sandeep Tiwary
In this case, you can use document.forms[0] to reference it if this is the first form in your page (index 1 for second, 2 for thrid etc.). -
Javascript Print Button using struts frmaework[ Go to top ]
- Posted by: Abhishek Tripathi
- Posted on: March 01 2006 11:33 EST
- in response to sandeep Tiwary
Hi ,
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.
Abhishek -
javascript with struts[ Go to top ]
- Posted by: Majid Kalkatechi
- Posted on: March 01 2006 15:14 EST
- in response to sandeep Tiwary
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[0]..... and for second form : document.forms[1]..... and so on.
2.In your JSP, you can write a hidden field that you know the name of it in javascript, and the value of that hidden is your form name, then use :
Var hiddenValue = document.getElementById("hiddenId").value;
document.forms[hiddenValue].......
where hiddenId is the Id attribute of the hidden field.