• 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

Javascript prompt box and jsp variable

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
How can i take the users entry from a prompt (javascript) dialog box and assign it to a jsp to pass it to a bean.
The reason is simple. I have a list of values that offers the possibility to add an extra option so i need to take the value and pass it
Thanks
Jeff
 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSP Page would contain the javascript that would present the dialogue box to the user and then get the value from the dialogue box and assign it to some variable. Then within the javascript, you can have the code <%=setBoxData(yourVariable)%> where setBoxData would be method from the bean. Of course, I mean simple beans.
I hope that provides a bit of direction.
Shama


[This message has been edited by Shama Khan (edited July 12, 2001).]
 
Jeff Dube
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks but there is a problem when i am trying it.
Here is part of my code with the generated error
What am i doing wrong?
Code:
<SCRIPT LANGUAGE="javascript">
function validateFields(objForm) //Receiving the form object
{
...
if (document.frmWork.lstWork.value == "Other")
{
newWorkType = prompt('Please, type your new work category.');
<%=inserList.setNewOption(newWorkType);%>
......
</script>
insertList is the name of my bean (simple bean)
And here is my error:
Error: Syntak error
Thank you
Jeff
 
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
you cant assign values from JavaScript to JSP directly.
JSP are running on server side and the thing displayed in your browser is pure HTML (and probably Javascript).
JavaScript is downloaded with the page and running on your computer in the browser's JavaScript engine.
what you need to do is to get the values from your prompt and addadd it as parameters to the URL of your JSP.
then call the this URL and in the JSP you can read the value with the getParameter(..) method.
as an alternative you can also set the value from javascript to a hidden field in a form (where the action is set to your jsp) and then submit the form (probably even easier).
hope this helps. di it ?
karl
 
His brain is the size of a cherry pit! About the size of this ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic