By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,028 Members | 1,784 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,028 IT Pros & Developers. It's quick & easy.

struts logic tag + javascript

P: 25
Hi,

My jsp has a text field company and i have two logic tags with properties years and none.
[HTML]
<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>

<logic:equal value="none" property="years" name="announcementListForm">
</logic:equal>[/HTML]


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

Expand|Select|Wrap|Line Numbers
  1. function showHint()
  2. {
  3.  
  4. if(document.forms[0].years.value==null || document.forms[0].years.value=="years"  )
  5. {
  6. document.forms[0].years.value="none";
  7. }
  8. }
  9.  
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
Oct 3 '08 #1
Share this Question
Share on Google+
5 Replies


Expert 10K+
P: 11,448
This is a JavaScript question; you've posted it in the Java forum. These two
languages have nothing to do with eachother. Do you want me to move your
question to the JavaScript forum?

kind regards,

Jos (moderator)
Oct 3 '08 #2

P: 25
sorry for posting here can move to javascript form



This is a JavaScript question; you've posted it in the Java forum. These two
languages have nothing to do with eachother. Do you want me to move your
question to the JavaScript forum?

kind regards,

Jos (moderator)
Oct 3 '08 #3

karthickkuchanur
100+
P: 156
Hi when load u load ur jsp it will check the year and nome whether they have the value it will display ur link.after that u have call
Oct 3 '08 #4

P: 93
Are you new to Javascript ?
The way you have interacted with the id is not correct.
you can use in this way

Expand|Select|Wrap|Line Numbers
  1. function check()
  2. {
  3.  var Field= $('Id of the field of which you want to validate').value;
  4.  
  5. if(Field=='Something' || Field='')
  6.      {
  7.  
  8.          alert('Hi Friend');
  9.      }
  10.  
  11. else
  12.    {
  13.      alert('Bye Friend');
  14.  
  15.    }
  16.  
  17.  
  18. }
Oct 3 '08 #5

acoder
Expert Mod 15k+
P: 16,027
@sqxbytes, show the client-side version (HTML) version of your code, i.e. how it turns out in the browser when you view the source.

@Rsmastermind, he's not used the ID. Also, the $() function assumes that it's been defined somewhere. I would suggest document.getElementById() unless you know someone's using Prototype or some other library supporting it.
Oct 4 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.