Javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Moh Alaj
    New Member
    • Feb 2012
    • 2

    Javascript

    I need the code that will show a text field if i clicked on the button ...
  • dushkin
    New Member
    • Feb 2012
    • 8

    #2
    A simple google search turned up with this link


    In case you don't know where to look on that page, I'll paste the code onto here

    Code:
    <script language=javascript type='text/javascript'>
    function hideField() {
    if (document.getElementById) { // DOM3 = IE5, NS6
    document.getElementById('textField').style.visibility = 'hidden';
    }
    else {
    if (document.layers) { // Netscape 4
    document.textField.visibility = 'hidden';
    }
    else { // IE 4
    document.all.textField.style.visibility = 'hidden';
    }
    }
    }
    
    function showField() {
    if (document.getElementById) { // DOM3 = IE5, NS6
    document.getElementById('textField').style.visibility = 'visible';
    }
    else {
    if (document.layers) { // Netscape 4
    document.textField.visibility = 'visible';
    }
    else { // IE 4
    document.all.textField.style.visibility = 'visible';
    }
    }
    }
    </script>
    The HTML for the text field

    Code:
    <input type="text" id="textField" />
    And the buttons

    Code:
    <input type="button" id="showField" onclick="showField()" />
    <input type="button" id="hideField" onclick="hideField()" />

    Comment

    • Moh Alaj
      New Member
      • Feb 2012
      • 2

      #3
      thank you dushkin but it seems the textfield is already there ...i need it visible unless i clicked on the button
      thank you again

      Comment

      • dushkin
        New Member
        • Feb 2012
        • 8

        #4
        If you are asking "How do I make a text field invisible upon the page loading?" then instead of a plain <body> tag, use <body onload="hideFie ld()">

        If your not asking that, and your asking "How do I make a text field disappear when I press the button" use the code I gave you above
        <input type="button" id="hideField" onclick="hideFi eld()" />

        Comment

        Working...