Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java Open Source > Struts
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Struts section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 2nd, 2008, 09:48 PM
Authorized User
 
Join Date: Sep 2008
Posts: 87
Thanks: 1
Thanked 0 Times in 0 Posts
Default struts+javascript

Hi,

My jsp has a text field company and i have two logic tags with properties years and none.
HTML Code:
<html:text property="company"  onChange="showHint()" />

<logic:equal value="year" property="years" name="announcementListForm">
<a title="year">By Year:</a>
<a title="2008" href="../announcementList.do?year=2008">2008 </a>
<a title="2007" href="../announcementList.do?year=2007">2007 </a>
<a title="2006" href="../announcementList.do?year=2006">2006</a>
</logic:equal>
[s][s][s] [/s][/s][/s]
<logic:equal value="none" property="years" name="announcementListForm">
</logic:equal>

i need to write a javascript such that when i change the value of my company in the text box i need to set the logic tag property to none ,only onChange().

i tried like

function showHint()
{

if(document.forms[0].years.value==null || document.forms[0].years.value=="years" )
{
document.forms[0].years.value="none";
}
}

when i tried this way i am getting

document.forms[0].years.value is null or not an object.


how to go ahead with this...

Thanks
Raj

 
Old October 7th, 2008, 03:04 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

First onChange() is a java script method and <logic:equal /> is a struts tag.This tag will be evaluated when you visit the page at server and result html will be sent to browser. And the showHint() java script method gets executed on browser when you change value of the text.

Coming to your problem. Have two html blocks for both the results [for value year and none] on the page and switch them using java script innerHtml attribute. If you place a container div [like <div id="testId">...</div> in which you'll place all the hyperlinks you want], and in showHint() method use document.getElementById() to get the reference of the above mentioned container div and use the innerHtml attribute to set/remove the links.

Hope i am helpful

- Rakesh
 
Old October 7th, 2008, 03:14 AM
Authorized User
 
Join Date: Sep 2008
Posts: 87
Thanks: 1
Thanked 0 Times in 0 Posts
Default

thanks for the suggestion






Similar Threads
Thread Thread Starter Forum Replies Last Post
struts actions package: "struts", other packages? ojasrege Struts 1 July 21st, 2007 06:02 AM
struts ahamad Struts 0 August 26th, 2006 02:31 AM
about struts kishore.dyn Struts 4 August 8th, 2006 01:28 AM
new to struts rakeshkumar Struts 4 April 29th, 2006 05:56 AM
How to get upgraded from Struts 1.1 to struts 1.2. [email protected] Struts 0 January 3rd, 2006 04:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.