• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Setting dynamic parameter values?

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to call my javaScript function with a parameter value that is determined dynamically. When I call my showWine function from my <a> tag I get an undefined variable error. What is the best way to code this simple functionality?
I have reduced my jsp code to illustrate my problem.

[ September 26, 2002: Message edited by: Rich Smyth ]
 
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe try this:
 
Rich Smyth
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks James it worked. I applied your idea to the code on which my simple example was based and also got that to work. But i'm not sure if I did it correctly.
I ultimately want to use the parameter of my showWine function as a parameter for a jsp. I had to build the url that uses this parameter in a separate statement, outside the open.window call. Is there a way to use just a single statement? I tried variations of ".../aboutTheFeaturedWine.jsp?promo=<%= feature %>" but that didn't work
The version of my function that works but is perhaps not elegant:
<SCRIPT LANGUAGE="JavaScript">
function showWine(feature) {
featurePage = "http://localhost:8080/WineProject/aboutTheFeaturedWine.jsp?promo=" + feature
var porps = window.open(featurePage, "windowFeaturedWine", "toolbars=1, scrollbars=1, menubars=0, resizable=1, width=400, height= 200");
}
</SCRIPT>
 
reply
    Bookmark Topic Watch Topic
  • New Topic