• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

implementing dependent select boxes in struts1.2.9 and netbeans6.5

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,I am using netbeans6.5 with struts1.2.9 framework.In a jsp page when the user selects a value from the list,based on that value next <html:select> tag options has to be populated from the server.For this i am extending myaction class to dispatchAction.I have also added the method to be invoked when the user selects a value from the first select <html:select> LOV(list of values).

Now the problem is i have added a javascript function getSecondListOfValues() for an onchange event of the first select tag like this


<html:form action="/Search.do" method="POST">

<html:select property="firstSelect" onchange="getSecondListOfValues()">
<htmlptionsCollections ....>/<html;optionsCollections>
</html:select>

<html:select property="secondSelect" onchange="getThirdListOfValues()">
<htmlptionsCollections ....>/<html;optionsCollections>
</html:select>

<html:select property="thirdSelect" >
<htmlptionsCollections ....>/<html;optionsCollections>
</html:select>

<html:submit value="Submit"></html:submit>

</html:form>

In javascript function:

function getSecondListOfValues()
{

var firstSelectedValue = document.getElementById("firstSelect");

document.myform.action.value="SearchAction"; // This is the action name that extends DispatchAction class
document.myform.method.value="getSecondList"; // This is the method in SearchAction class

return true;
}

struts-config.xml:

<action name="searchFormBean"
path="/Search"
parameter="method"
type="com.training.reps.action.SearchAction">
<forward name="success" path="/SearchOrders.jsp"/>
</action>


The error:

I get javascript error saying myform is null or not an object.

I understand that i have not specified the form name in <html:form> tag as struts-html.tld doesnt let to specify and gets an error "name attribute is not declared in struts-html.tld".
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i think you are assigning value to action and method.instead of that assign action direcly in javascript

In javascript function:

function getSecondListOfValues()
{

var firstSelectedValue = document.getElementById("firstSelect");

document.myform.action="SearchAction"; // This is the action name that extends DispatchAction class
document.myform.method="getSecondList"; // This is the method in SearchAction class

return true;
}
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@rk: If "action" and "method" are form properties then they need to have their *values* set, otherwise you'd just be overwriting DOM objects with strings--almost certainly not what's intended.
 
And tomorrow is the circus! We can go to the circus! I love the circus! We can take this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic