Win a copy of Java Challengers this week in the Java in General forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

JSP values into HTML hidden fields ? or javascript ?

 
Ranch Hand
Posts: 1479
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to either have values in your JSP put into a hidden field on the same JSP page?
Can JSP send values to javascript on the same page in any way?
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's an example that illustrates using the value of a variable defined in a JSP page as the value of a hidden field of an HTML form and passing the value of a variable defined in a jsp page to a javascript function:

After launching the above jsp page, if clicking on "open window" a new browser window that points to http://www.javaranch.com should open. If you view the source of the page, you should see that the value of the hidden variable of the html form is equal to "hidden".
NOTE: For some reason I couldn't get the post to submit when typing "onclick", so I spelled it "onclik".
 
frank davis
Ranch Hand
Posts: 1479
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!!!
All the examples I had in my JSP book said <=% %> tag would display output. If I had been thinking, I would have realized its just generating text like anything else on the web page and would be interpreted by the browser appropriately in each situation... :roll:
 
And when my army is complete, I will rule the world! But, for now, I'm going to be happy with this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic