Results 1 to 6 of 6

Thread: show and hide

  1. #1
    Join Date
    Aug 2008
    Posts
    23
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Smile show and hide

    the user could only see the text "This will hide" and the show-hide link
    When the user clicks the show-hide link, it will show an input field and it will hide the text "This will hide"
    could you please help me?

  2. The Following User Says Thank You to abs0lut For This Useful Post:

    hosdank (08-18-2008)

  3. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    When showing and hiding things you have two basic approaches (there are other ways):

    • The element's visibility style property (hidden or visible)
    • The element's display style property (none or usually block or inline)


    With display, the seen property varies depending upon the type of element (what display values it can support) and how you want it to display when it is seen.

    Setting visibility hidden only removes the element from view. Setting display to none removes the element from the flow (layout) of the document, so can make things jump around as well as disappear.

    You could do:

    Code:
    <span id=txt>This will hide</span> 
    <a href="#" 
    onclick="document.getElementById('txt').style.visibility='hidden';
    document.getElementById('inp').style.visibility='visible';
    return false;">Do it</a> 
    <input style="visibility:hidden;" type="text" id="inp">
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. The Following User Says Thank You to jscheuer1 For This Useful Post:

    hosdank (08-18-2008)

  5. #3
    Join Date
    Aug 2008
    Posts
    23
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default

    the input field should be placed where the text "This will hide" appears. please help..
    thanks.
    Last edited by abs0lut; 08-17-2008 at 11:21 PM.

  6. The Following User Says Thank You to abs0lut For This Useful Post:

    hosdank (08-18-2008)

  7. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    <a href="#" 
    onclick="document.getElementById('txt').style.display=!this.onclick.tog? 'none' : '';
    document.getElementById('inp').style.display=!this.onclick.tog? '' : 'none';
    this.onclick.tog = !this.onclick.tog;
    return false;">Do It</a> 
    <span id=txt>This will hide</span><input style="display:none;" type="text" id="inp">
    I added a feature too. Can you guess what? Here's the bare bones version:

    Code:
    <a href="#" 
    onclick="document.getElementById('txt').style.display='none';
    document.getElementById('inp').style.display='';
    return false;">Do It</a> 
    <span id=txt>This will hide</span><input style="display:none;" type="text" id="inp">
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. The Following User Says Thank You to jscheuer1 For This Useful Post:

    hosdank (08-18-2008)

  9. #5
    Join Date
    Jul 2008
    Posts
    65
    Thanks
    42
    Thanked 0 Times in 0 Posts

    Default

    Haha. I was about to post the exact same question, then I got on and saw this. Thanks

  10. #6
    Join Date
    Aug 2008
    Posts
    23
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    Code:
    <a href="#" 
    onclick="document.getElementById('txt').style.display=!this.onclick.tog? 'none' : '';
    document.getElementById('inp').style.display=!this.onclick.tog? '' : 'none';
    this.onclick.tog = !this.onclick.tog;
    return false;">Do It</a> 
    <span id=txt>This will hide</span><input style="display:none;" type="text" id="inp">
    I added a feature too. Can you guess what? Here's the bare bones version:

    Code:
    <a href="#" 
    onclick="document.getElementById('txt').style.display='none';
    document.getElementById('inp').style.display='';
    return false;">Do It</a> 
    <span id=txt>This will hide</span><input style="display:none;" type="text" id="inp">
    thank you very much

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •