Make button invisible in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ghjk
    Contributor
    • Jan 2008
    • 250

    #1

    Make button invisible in php

    I have a menu which is contain image buttons. I want to hide some buttons in some pages. This is my code and it's not working. I couldn't find the error. Please help me.
    Code:
    <script type="text/javascript">
         document.form1.btn1.style.visibility="hidden";
    </script>
    <body><form name="form1" >
              
                    <table border="0" cellpadding="0" cellspacing="3">
                        <tbody>
                            <tr>
                                <td><html:link action="/loadp1"><img src="images/Btn1.jpg" width="120" height="20"  border="0"  name="btn1"/></html:link></td>
                                <td><html:link action="/admin"><img src="images/AdminBtn.jpg" width="120" height="20"  border="0" id="admin"/></html:link></td>
                                .............
                            </tr>
                        </tbody>
                    </table>
            </form>
      
        </body>
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    give it an id and use:
    Code:
    document.getElementById('yourId').style.visibility='hidden';
    kind regards

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      Code:
      <html:link action="/loadp1">
      I don’t know what this is, but it’s not HTML (as it is now)

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        looks like struts-syntax ...and should render as a simple anchor tag?

        kind regards

        Comment

        • ghjk
          Contributor
          • Jan 2008
          • 250

          #5
          Originally posted by gits
          give it an id and use:
          Code:
          document.getElementById('yourId').style.visibility='hidden';
          kind regards
          I put
          Code:
          document.getElementById(btn1).style.visibility='hidden';
          . and change the image id as btn 1. but it's not working.

          Comment

          • ghjk
            Contributor
            • Jan 2008
            • 250

            #6
            Originally posted by Dormilich
            I don’t know what this is, but it’s not HTML (as it is now)
            It's struts syntax. just a normal page load

            Comment

            • gits
              Recognized Expert Moderator Expert
              • May 2007
              • 5390

              #7
              Originally posted by ghjk
              I put
              Code:
              document.getElementById(btn1).style.visibility='hidden';
              . and change the image id as btn 1. but it's not working.
              you have to pass the id as a string:

              Code:
              document.getElementById('btn1').style.visibility='hidden';

              Comment

              Working...