User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 429,747 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,081 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 946 | Replies: 7
Reply
Join Date: Jun 2008
Posts: 5
Reputation: caprisan06 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
caprisan06 caprisan06 is offline Offline
Newbie Poster

How to embed JavaScript code into JSP...

  #1  
Jun 19th, 2008
Hi,

I want to write the below javascript code into my JSP page directly...Can you please help?

JSP code...

  1. <span class="mini">
  2. <html:link href="#" styleClass="bouton" onclick="return submit_form_with_parameters('delegationForm', 'delegation', 'noInit=Y');">
  3. <bean:message key="rh2u.deleg.label.etape0.label.chercher" />
  4. </html:link>
  5. </span>

JavaScript code...

function submit_form_with_parameters(strFormName, strAction, parameters){
	objForm = eval("document." + strFormName);
	objForm.action = strAction + ".do?" + parameters;
	objForm.submit();

I want to write the function submit_form_with_parameters directly into JSP page.

Please help.
Last edited by peter_budo : Jun 19th, 2008 at 4:39 pm. Reason: Keep It Organized - please use [code]tags
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2006
Location: Noida, India
Posts: 158
Reputation: Luckychap is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 17
Luckychap's Avatar
Luckychap Luckychap is offline Offline
Junior Poster

Re: How to embed JavaScript code into JSP...

  #2  
Jun 19th, 2008
put this in in your JSP page:

<%=
"function submit_form_with_parameters(strFormName, strAction, parameters){
objForm = eval(\"document.\" + strFormName);
objForm.action = strAction + \".do?\" + parameters;
objForm.submit();
"

%>
OR
<%
         String jsCode = "function submit_form_with_parameters(strFormName, strAction, parameters){
objForm = eval(\"document.\" + strFormName);
objForm.action = strAction + \".do?\" + parameters;
objForm.submit();
";

%>

<%=jsCode%>
Last edited by Luckychap : Jun 19th, 2008 at 8:27 am.
When you think you have done a lot, then be ready for YOUR downfall.
Reply With Quote  
Join Date: Jun 2008
Posts: 16
Reputation: icorey has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 3
icorey icorey is offline Offline
Newbie Poster

Re: How to embed JavaScript code into JSP...

  #3  
Jun 19th, 2008
what would prevent you from just using html, as in

  1. <script type="text/javascript">
  2. ...js code...
  3. </script>

???
Reply With Quote  
Join Date: Aug 2006
Location: Noida, India
Posts: 158
Reputation: Luckychap is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 17
Luckychap's Avatar
Luckychap Luckychap is offline Offline
Junior Poster

Re: How to embed JavaScript code into JSP...

  #4  
Jun 19th, 2008
Actually icorey is also correct. If u have to display static HTML its good to write in icorey way.
When you think you have done a lot, then be ready for YOUR downfall.
Reply With Quote  
Join Date: Jun 2008
Posts: 5
Reputation: caprisan06 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
caprisan06 caprisan06 is offline Offline
Newbie Poster

Re: How to embed JavaScript code into JSP...

  #5  
Jun 19th, 2008
Thanks guys...I did as icorey said.....now the problem is .....when i click on the submit button...I can not see the internet explorer progress bar...but when I execute the same in Mozilla firefox, I can see the progress bar. and process is getting completed in both the cases.
My users are using internet explorer and can not see the progress.....
Is there any change required to be done?

thanks for your help.
Reply With Quote  
Join Date: Jun 2008
Posts: 5
Reputation: caprisan06 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
caprisan06 caprisan06 is offline Offline
Newbie Poster

Re: How to embed JavaScript code into JSP...

  #6  
Jun 19th, 2008
Thanks guys...I did as icorey said.....now the problem is .....when i click on the submit button...I can not see the internet explorer progress bar...but when I execute the same in Mozilla firefox, I can see the progress bar. and process is getting completed in both the cases.
My users are using internet explorer and can not see the progress.....
Is there any change required to be done?

thanks for your help.
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,752
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 199
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: How to embed JavaScript code into JSP...

  #7  
Jun 21st, 2008
no. that's defined by the browser. Most likely IE is just faster than is FF (wouldn't surprise me, it is faster in my experience) so it's getting a response and processing it before it gets a chance to display the bar.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote  
Join Date: Jun 2008
Posts: 5
Reputation: caprisan06 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
caprisan06 caprisan06 is offline Offline
Newbie Poster

Re: How to embed JavaScript code into JSP...

  #8  
Jun 21st, 2008
thanks for your mail....but the problem is ....it is displaying results after 15-20 seconds.....in both the cases of IE and Firefox. Results are coming at equal time in both but IE is not showing the progress bar.
Thanks
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JSP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JSP Forum

All times are GMT -4. The time now is 3:12 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC