• Post Reply Bookmark Topic Watch Topic
  • New Topic

set text filed values based on drop down selection  RSS feed

Deeps Mistry
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,

I have a drop down with two values : 'nos.' and 'kg' and i have 10 text fields.

By default the value of the text field is 'nos.' .
If i select 'kg' in the drop down all the text fields should change to kg.

Here is my code:

<html:select property="UOM" onchange="changeValue(this.value);">
<htmlption value="nos."></htmlption>
<htmlption value="kg"></htmlption>

<logic:iterate id="lines" name="purchaseOrderBeanForm" property="lines">
<td><%=i %></td>
<td align="center"><html:text indexed="true" name="lines" property="POD"/></td>
<td align="center"><html:text indexed="true" name="lines" property="PON"/></td>
<td><html:text indexed="true" name="lines" property="POQ" size="6"/></td>
<td><html:text indexed="true" name="lines" property="UOM1" size="4" value="nos."/></td>
<% i++; %>

I am using DynaActionForm.

the entry in struts-config is as follows:
<form-bean name="purchaseOrderBeanForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="lines" type="ActionForm.AddPOBean[]" size="10" />
<form-property name="selected" type="java.lang.String" />
<form-property name="arrCustID" type="java.util.ArrayList" />
<form-property name="UOM" type="java.lang.String" />
<form-property name="POB2B" type="java.lang.String" />
<form-property name="POTX" type="java.lang.String" />
<form-property name="PONO" type="java.lang.String" />

This is what i tried:
function changeValue(value)
var weight = value;
var i = 0;
document.purchaseOrderBeanForm.lines[1].UOM1.value = "kg";


Please help me out!!!

Bear Bibeault
Author and ninkuma
Posts: 66258
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
David Newton
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Really, it's a JavaScript question.

You neglect to actually mention *what* doesn't work, just saying "it doesn't work" is not helpful: TellTheDetails.

That said, if you're trying to change 10 text fields, it'd make sense to have the JavaScript change 10 text fields--yours changes only a single text field, which is around 9 short. Perhaps a loop, or in any reasonable JavaScript library, a selector with a function.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!