Hi hem,

Here is an example

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function DropDownMenu(entered) {
 alert("Entering DropDownMenu");
 alert("The selected value is " + entered.value);
 alert("The selected index is " + entered.selectedIndex);
 codetext = entered.options[entered.selectedIndex].text;
 alert("The selected options is " + codetext);
 alert("Exiting DropDownMenu");
}
//-->
</SCRIPT>
</HEAD>

<BODY>
<FORM METHOD=POST ACTION="">
Sample select box
<SELECT NAME="idSelect" id="idSelect" onChange="DropDownMenu(this)" >
<option value="Code_1">One</option>
<option value="Code_2">Two</option>
<option value="Code_3">Three</option>
</SELECT>
</FORM>
</BODY>
</HTML>


Replace the SELECT box code with your struts html:select code. While
replacing the SELECT code, ensure that you have the NAME of the ITEM
information as the displayed text of the option box and the CODE of the
ITEM information as the value of the option. Or vice versa. This way you
can access both the ITEM code and item name. In the javascript code set
the hidden variable with the SELECTED ITEM's text.


Have a Good Day!!!
Best Regards
Pal


-----Original Message-----
From: hem hem [mailto:[EMAIL PROTECTED] 
Sent: Sunday, November 27, 2005 3:44 AM
To: Struts Users Mailing List
Subject: Re: saving a value in jsp?

Hi ,
   
  you said
   
  But if you stick to this then you can create a hidden field called
name and
on the onChange of the dropdown list set the value of the hidden field
to
the selected name.
   
  i was struct here mate.i already used hidden field to achieve this but
i am getting the (name)value of the last selected item in the drop down.
  can you please help me how can i achieve this by onclick?
   
  my code is like this
   
  <td>
  <html:select property="item.code">   
     <logic:iterate id="itemType" 
name="<%=WebConstants.getItemTypeListName()%>">
      <option value='<bean:write
name="ItemType" property="code"/>'><bean:write
       name="ItemType"
property="name" /></option>     
     </logic:iterate>      
    </html:select>
  <imput type="hidden" name="item.code" value="<bean:write
name="ItemType"
property="name" />"/>
  </td>
   
  here the last item in the dropdown is getting populated to my name
field not the selected one.
   
  can you plese help me to get the selected one(on using onclick)?
   
  regards and many thanks in advance
   
  
 
   
   
  

Tamas Szabo <[EMAIL PROTECTED]> wrote:
  Hi,

I think somebody already explained you that you don't need the name.
In the Action to which you forward you can loop up the name based on the
code.

But if you stick to this then you can create a hidden field called name
and
on the onChange of the dropdown list set the value of the hidden field
to
the selected name.


Tamas


On 11/25/05, Kanuri, Chand wrote:
>
> hi all,
> i have a dropdown list in my struts web app,
> i am having a form in which a bean is instatiated(bean has 2
properties
> "name" and "code").
>
> i am using like this in the jsp:
>
> 
>
> >
> name="">
> > name="ItemType" property="code"/>'>> name="ItemType"
> property="name" />
> 
>
>
> 
>
> each "itemType" has "code" and "name".
> when the user clicks on the item name on the dropdown item beans
"code" is
> populating.now i need to populate "name" aswell at the sametime using
> hidden
> property.
>
> i want to save tha value of name in the jsp to use it later to
populate
> "name" in my form using hidden property?
>
> do anyone have idea how to save the value in jsp?
>
> regards and thanks in advance
>
>
> This e-mail (and any attachments) may contain privileged and/or
> confidential information. If you are not the intended recipient please
do
> not disclose, copy, distribute, disseminate or take any action in
reliance
> on it. If you have received this message in error please reply and
tell us
> and then delete it. Should you wish to communicate with us by e-mail
we
> cannot guarantee the security of any data outside our own computer
systems.
> For the protection of Legal & General's systems and staff, incoming
emails
> will be automatically scanned.
>
> Any information contained in this message may be subject to applicable
> terms and conditions and must not be construed as giving investment
advice
> within or outside the United Kingdom.
>
> The following companies are subsidiary companies of the Legal &
General
> Group Plc which are authorised and regulated by the Financial Services
> Authority for advising and arranging the products shown: Legal &
General
> Partnership Services Limited (insurance and mortgages), Legal &
General
> Insurance Limited (insurance), Legal & General Assurance Society
Limited
> (life assurance, pensions and investments), Legal & General Unit Trust
> Managers Limited and Legal & General Portfolio Management Services
Limited
> (investments).
>
> They are registered in England under numbers shown.
> The registered office is Temple Court, 11 Queen Victoria Street,
London
> EC4N 4TP.
>
> Legal & General Partnership Services Limited: 5045000 Legal & General
> Assurance Society Limited: 166055 Legal & General (Unit Trust
Managers)
> Limited: 1009418 Legal & General (Portfolio Management Services)
Limited:
> 2457525 Legal & General Insurance Limited: 423930
>
> They are registered with the Financial Services Authority under
numbers
> shown. You can check this at www.fsa.gov.uk/register
>
> Legal & General Partnership Services Limited: 300792 Legal & General
> Assurance Society Limited: 117659 Legal & General (Unit Trust
Managers)
> Limited: 119273 Legal & General (Portfolio Management Services)
Limited:
> 146786 Legal & General Insurance Limited: 202050
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
  


                
---------------------------------
 Yahoo! Music Unlimited - Access over 1 million songs. Try it free.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to