struts logic tag + javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sgxbytes
    New Member
    • Sep 2008
    • 25

    struts logic tag + javascript

    Hi,

    My jsp has a text field company and i have two logic tags with properties years and none.
    [HTML]
    <html:text property="compa ny" onChange="showH int()" />

    <logic:equal value="year" property="years " name="announcem entListForm">
    <a title="year">By Year:</a>
    <a title="2008" href="../announcementLis t.do?year=2008" >2008 </a>
    <a title="2007" href="../announcementLis t.do?year=2007" >2007 </a>
    <a title="2006" href="../announcementLis t.do?year=2006" >2006</a>
    </logic:equal>

    <logic:equal value="none" property="years " name="announcem entListForm">
    </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

    Code:
    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
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    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)

    Comment

    • sgxbytes
      New Member
      • Sep 2008
      • 25

      #3
      sorry for posting here can move to javascript form



      Originally posted by JosAH
      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)

      Comment

      • karthickkuchanur
        New Member
        • Dec 2007
        • 156

        #4
        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

        Comment

        • Rsmastermind
          New Member
          • Sep 2008
          • 93

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

          Code:
          function check()
          {
           var Field= $('Id of the field of which you want to validate').value;
          
          if(Field=='Something' || Field='')
               {
          
                   alert('Hi Friend');
               }
          
          else
             {
               alert('Bye Friend');
          
             }
          
          
          }

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            @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.getEle mentById() unless you know someone's using Prototype or some other library supporting it.

            Comment

            Working...