Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use JavaScript to set form values?

 
rick collette
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • 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,
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A little JSTL should do the trick:

<input name="myTextField" type="text" value="<cut 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
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64824
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, no need to bring in things such as Struts when JSTL and JSP can do it for you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic