• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is it possible to embed jsp tags in javascript??

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to embed jsp tags in javascript??
I want to have only one html form, yet submit data to different pages for processing. Submit buttons call corresponding jscript method with onClick event...Problem is, I want to append form data to the url, and it's static in the below functions.
I want to do something like this....

<script language = "JavaScript">
function onEdit()
{
document.form1.action = "edit.jsp" //but I want to append data..something like "edit.jsp?id=<%=id%>"
}
function onReport()
{
document.form1.action = "report.jsp"
}
</script>
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bill,
If "id" is known when the jsp is writing out the HTML code you can do that. If it is part of what the user selected on the form, you can't. But since you are using the action and submit semantics, all the form parameters gets passed regardless of what action you submit to.
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It all depends on what you want to do.
If you want to create Javascript on the server before sending it to the client, that's the way to do it.
If you expect the JSP code to be executed during a call to the Javascript function, you're thinking wrong.
 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
You can set the mode for every opration like when user select the Report the set one hidden property and assing the value report to it , if user select the edit the change its value to edit , in java script you can check the value of that hidden prpoerty and call the appropreate action for this

eg. if user press edit the
document.form.mode.value ='edit
when user click on Report then
document.form.mode.value ='edit

In java Script
Function OnSubmit(Mode)
{
if mode == 'EDIT'
form.action = edit.jsp
else
if mode = 'REPORT'
from.action = report

.....
and so on you can do this


Regards
Santosh
}
reply
    Bookmark Topic Watch Topic
  • New Topic