Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9061477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:29:39+00:00 2026-06-16T15:29:39+00:00

I have this simple hide/show input box code, but I want to change it

  • 0

I have this simple hide/show input box code, but I want to change it so that you don’t see all the links at once but instead only the links that have been clicked and the one link after the last one that was clicked so in the beginning only link 1 is shown. Then if it is clicked only link 1 and 2 are shown and if link 2 is clicked only link 1,2 and 3 are shown and so on, is there a way to adapt this code to make that possible?

<script type="text/javascript">

function show(id){ 
if(document.getElementById(id).style.display=="none")
{ 
   document.getElementById(id).style.display="block"  
} 
else{ 
       document.getElementById(id).style.display="none" 
    } 
                 } 

</script>

<a href="#null" onclick="show('t1')">Link 1</a> <input type="text" id="t1"    
 style="display:none"><BR>
<a href="#null" onclick="show('t2')">Link 2</a> <input type="text" id="t2"   
style="display:none"><BR> 
<a href="#null" onclick="show('t3')">Link 3</a> <input type="text" id="t3" 
style="display:none"><BR>
<a href="#null" onclick="show('t4')">Link 4</a> <input type="text" id="t4"   
style="display:none"><BR>
<a href="#null" onclick="show('t5')">Link 5</a> <input type="text" id="t5"    
style="display:none"><BR>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T15:29:40+00:00Added an answer on June 16, 2026 at 3:29 pm

    based on assuming option ‘a’ from my comment on the original post, change the code slightly to:

    <script type="text/javascript"> 
    function show(id){ 
      if(document.getElementById(id+"-link").style.display=="none") { 
        document.getElementById(id+"-link").style.display="block";  
        document.getElementById(id+"-input").style.display="block";  
      } 
    } 
    </script>
    
    <a href="#null" onclick="show('t2')">Link 1</a> <input type="text" id="t1"><BR>
    <a href="#null" style="display:none" id="t2-link" onclick="show('t3')">Link 2</a> <input type="text" id="t2-input" style="display:none"><BR>  
    <a href="#null" style="display:none" id="t3-link" onclick="show('t4')">Link 3</a> <input type="text" id="t3-input" style="display:none"><BR>
    

    Basically, offset the id’s in the call to ‘show’ so that clicking each link shows the next one, and don’t hide the first. note that ‘t2’ etc is now just part of the id, and the ‘show’ function has to expand it to include all elements to show/hide

    I’ve not bothered to include a separate toggle to show/hide the inputs, and i’ve removed the code to hide the links if the user clicks a second time

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this simple code, using Joda-time. Works fine, but I have a problem.
i have a simple show/hide div and a form on the div, but when
I have a simple dropdown menu and I'd like to have this menu close/hide
I have this simple piece of code : int a = 1, b =
I have this simple code (for making things shorted, the important bits are probably
I have this simple script that I'm working on. I must admit, I'm totally
I have this simple code in a WPF application: ThreadStart start = delegate() {
i have this simple question please. I have this part of code which sets
I have this simple scenario (simplified for the sake of this question): <input type=text
I have input with password type. And I want to do simple thing. If

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.