• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Use JavaScript to set form values?

 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, guys:

I have a JSP page with a form of text boxes and dropdowns. Every time
when a user comes to this page, I will try to set form fields with values I
got from database which are put in session. I know we can use struts ActionFomrm to achieve this, but I cannot use Struts for this somehow. Is there any way I can do this using JavaScript or anything else?

regards,
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A little JSTL should do the trick:

<input name="myTextField" type="text" value="<c:out value="${myBean.myProperty}"/>">

or if you're using a JSP 2.0 web container, simply:

<input name="myTextField" type="text" value="${myBean.myProperty}">
[ March 02, 2006: Message edited by: Merrill Higginson ]
 
rick collette
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Merrill Higginson:
A little JSTL should do the trick:

<input name="myTextField" type="text" value="<c ut value="${myBean.myProperty}"/>">

or if you're using a JSP 2.0 web container, simply:

<input name="myTextField" type="text" value="${myBean.myProperty}">

[ March 02, 2006: Message edited by: Merrill Higginson ]



Thanks for the reminder. I guess I can just use JSP expressions to populate form values.
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup, no need to bring in things such as Struts when JSTL and JSP can do it for you.
 
permaculture is a more symbiotic relationship with nature so I can be even lazier. Read tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic