• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

html options doubt in struts

 
Phanindra varma
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Please help me out from this situation.
I wrote a code like this.

<html:select property="entity">
<html ptions name="entityValue"/>
</html:select>

Here i am able to populating the values from collection. I wrote a javascript function for moving the values from left select area to right select area for that if i select any value from the options it should return true or false based on that only i will move that value from left to right.

Ex in Javascript :

if (from.options[i].selected) {
// Here i am writing the actual code
}
The above code is working if i am using HTML options but how will i write the equalent code when i am using STRUTS HTML options.

Please Help me.... I am eagerly waiting for the reply.
Thanks in Advance.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Phanindra,
The code is the same idea. Note that the name of the form element is the name of the property and the name of the form is in the struts config file's form defintion.

So you have:
document.formInStrutsConfig.entity.options[...
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When writing javaScript for a Struts application it's important to remember two things:

1 - A struts JSP with it's html:xxx tags is a server-side technology that translates your instructions into pure html and then sends that html back to the browser. The browser then interprets the html and causes the page to be displayed.

2- JavaScript is a client-side technology that acts upon the pure html that is sent to the browser, not on the jsp tags themselves.

As long as you bear in mind these two things, javaScript programming for Struts is no different than javaScript for any other web application. I find that it's helpful to make frequent use of my browser's "view source" function so that I can see the actual html that is being displayed on the page. Once I know this, it's relatively easy to write javaScript for that page.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic