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 8827317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:20:38+00:00 2026-06-14T07:20:38+00:00

I am trying to write a PHP Java Script, but struggling to write in

  • 0

I am trying to write a PHP Java Script, but struggling to write in this section of coding.

I am trying to make a buttom in form in that opens

The code I have written so far is

function display(e){
    if (e.clicked)
        document.getElementById('2').style.display = 'none';
    else
        document.getElementById('2').style.display = 'block';

and the FORM CODE is;

 <input type="button" value=" Book Now " onClick="display(this)"/></input>

any help to point out my clear mistakes would be great, the live code can be seen at
http://affordablecleaners.co.uk/quote/

Thanks,

Henry

  • 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-14T07:20:39+00:00Added an answer on June 14, 2026 at 7:20 am

    Try something similar to the following

    var i = 0;
    var display = function() {
        document.getElementById('2').style.display = (i++ % 2) ? "none" : "block";
    };
    

    Essentially, we’re creating a variable i and increasing it by one every time the function is called. If, when the function is called, i is an even number, then we set it to display: block. Otherwise, set it to display: none.

    The biggest downside to this solution is cluttering the global scope. If this is an issue, you can also do the following.

    var display = function() {
        document.getElementById('2').style.display = (document.getElementById('2').style.display == "none") ? "block" : "none";
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a PHP script that can upload multiple files. for($i=0;$i<count($_FILES['uploadimg']['name']);$i++){
I am trying to write a PHP script that uses the pdftk app to
I am trying to write a PHP script that listens for incoming $_REQUEST or
I am trying to write a bash or PHP script that will execute a
I'm trying to write a php function that gets all the basic food data.
In PHP I am trying to write an article section. A totally fictitious article
I'm trying to write a script in Greasemonkey that will generate link's in a
i am trying to validate a form with java script .. yet the javascript
I am trying to write a php page that will load several different websites
I'm trying to write an html/javascript set (to be interpreted in PHP) that allows

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.