473,785 Members | 2,824 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I need help hiding/ disabling buttons.

Blue1244
39 New Member
Hello, I'm 13 trying my luck with js. I am trying to make an in browser game. It is a simple math game, just basic stuff.I am trying to have a list of buttons on the webpage, but you need to go down in order without being able to pick question two instead of question one. How do i make the other buttons inactive until completion of the first question.

Here is my code:(Not really good)
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. </head>
  4. <script language="javascript">
  5. alert("Are you sure you want to play this game?");
  6. var Name = prompt("What is your name?");
  7. </script>
  8.  
  9. <script type="text/javascript">
  10. document.write(Name);
  11. </script>
  12.  
  13. <center><button id="button1" onClick="start()">First Question</button></center>
  14.  
  15. <script>
  16. function start() {
  17. var one = prompt("What is 3 * 4 ?");
  18.  
  19. if (one!=12)
  20.   {
  21.    {
  22.  alert("Correct");
  23.   }
  24.  else 
  25.  {
  26.  alert("Incorrect");
  27.  }
  28. }
  29. </script>
  30. </html>
  31.  
Aug 21 '13 #1
23 1547
Dormilich
8,658 Recognized Expert Moderator Expert
It is a simple math game
3 * 4 = 7 ???

some notes:
  • missing Doctype
  • missing <title>
  • the language attribute is deprecated, use type="text/javascript"
  • <center> is deprecated, use CSS instead
  • several typos
  • document.getEle mentById() is a function, not a primitive for assignment
  • if/else: check the brace count
Aug 22 '13 #2
Blue1244
39 New Member
yeah that's just some mixed up code I was doing this at 4:40 AM before school started and some stuff I was working on and decided not to use it and forgot to remove some stuff.and i only gave you the important stuff because I didn't want to give every thing because that would have made more lines. I was planning on removing the
Expand|Select|Wrap|Line Numbers
  1. document.getElementById()
. Thank you for the help on my code. Oh and the
Expand|Select|Wrap|Line Numbers
  1. document.getElementById()
was when i was trying to figure out how to delete a button, witch is what i asked this question for in the first place.
Aug 22 '13 #3
Dormilich
8,658 Recognized Expert Moderator Expert
was when i was trying to figure out how to delete a button
simple enough:
Expand|Select|Wrap|Line Numbers
  1. // or whatever you like to reference the button
  2. var button = document.getElementById("theButton");
  3.  
  4. button.parentNode.removeChild(button);
Aug 22 '13 #4
Blue1244
39 New Member
Thank you now I am going to input this so i can try to get this working. After I get this working it should be a smooth road the rest of the way. Unless I wanted to add a score and scoreboard but that will be later.
Aug 22 '13 #5
Blue1244
39 New Member
Wait is there a way of deleting the question 2 buttons and above. on entering the page, and enabling them after question one is finished? Sorry if i sound like i need help on everything.
Aug 22 '13 #6
Blue1244
39 New Member
I'm going to try to keep the code UTD as much as i can on here.
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. </head>
  5. <script type="text/javascript">
  6. var w= confirm("Are you sure you want to play this game?");
  7.  
  8.     if (w==true)
  9.     {
  10.     var button = document.getElementById("theButton");
  11.  
  12.     button.parentNode.removeChild(button);
  13.     }
  14.     else
  15.     {
  16.     window.close();
  17.     }
  18. </script>
  19. <script type="text/javascript">
  20. var Name = prompt("What is your name?");
  21. </script>
  22.  
  23. <script type="text/javascript">
  24. document.write(Name);
  25. </script>
  26.  
  27. <center><button id="button1" onClick="start()">First Question</button></center>
  28.  
  29. <script type="text/javascript">
  30. function start() {
  31. var one = prompt("What is 3 * 4 ?");
  32.  
  33. if (one!=12)
  34.   {
  35.    {
  36.  alert("Correct");
  37.   }
  38.  else 
  39.  {
  40.  alert("Incorrect");
  41.  }
  42. }
  43. </script>
  44. </html>
  45.  
Aug 22 '13 #7
Dormilich
8,658 Recognized Expert Moderator Expert
I would disable the buttons rather than removing ...

anyways, your if/else is still wrong.
Expand|Select|Wrap|Line Numbers
  1. // with appropriate indenting
  2. if (...)
  3. {
  4.     {
  5.         alert(...);
  6.     }
  7.     else
  8.     {
  9.         alert(...);
  10.     }
  11. }
I’m pretty sure that throws an unexpected "else" error.
Aug 22 '13 #8
Blue1244
39 New Member
Okay I will try to fix this as soon as possible, I go to school in about 1 hour. No, I'm not sleep deprived I have a really weird sleep schedule.
Aug 22 '13 #9
Blue1244
39 New Member
And the title of this question is "I need help removing/disabling buttons" not to be rude but you were the one who brought up removing so I thought that would work. Sorry if I sound rude.
Aug 22 '13 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
3537
by: Philippe Meunier | last post by:
Hi, I am using the .NET toolbar with VB.NET 2003. My toolbar uses icons images that are actually PNG files and uses alpha blending on it. So to make alpha blending work correctly with the Toolbar and the Imagelist I had to use a tricky method with API calls that is described like this by a MS MVP : 1) Use v6 of the common controls (have a manifest) 2) Load the PNG using GDI+
16
2061
by: Ralph Freshour | last post by:
How can I disable a button once it has been clicked? I want to prevent the user from clicking on it twice if they have a slow connection. Thanks...
5
5056
by: Lyn | last post by:
Hi, I hope someone can help. I have a main form which mostly fills the Access window. In the bottom half of this form I have a tab control to display various types of data related to the main form record. In each page of the tab control, there are three buttons: Add, Update, Delete. Any of these buttons will open another, smaller form to add, update or delete the related data record. Originally, I had placed the smaller form such...
2
1382
by: Michael Groeger | last post by:
Hi all, I want to disable a button after it's clicked on the clients side, so that this cannot be clicked twice. I tried this with adding the "onclick" attribute to the button and disable the button then in javascript. Then I tried it using Page.RegisterOnSubmitStatement(), but when I then click the button the Click event is not fired on server side. Any ideas?
1
4393
by: mssbass | last post by:
In order to disable the previous and next buttons on my form, I followed the attached code. The buttons seem to work fine except for one thing. When the form first opens, the next button is disabled; however, if you click on the forward arrow on the scroll bar and click the previous button which takes you back to the 1st form, the next button is now enabled! What am I doing wrong? I just need the next button to be ENABLED when I open...
3
1440
by: hplayer03 | last post by:
I'm having major issues disabling a submit button after a form has been filled out. Nothing I've tried so far has helped. I've put if(!Page.IsPostBack) { Session=false; } else if((bool)Session==true) { contiuneCode();
0
944
by: andymcintosh85 | last post by:
Hi, I have designed a macro which prints out the first 2 pages of a word document. The Macro is assigned to a command button which is at the bottom of the second page. At the moment, the macro works fine, but the command button is being shown on the print out too. How can i adopt hiding the command button into my vb code? Many thanks Andrew
9
7146
by: poml | last post by:
Hello, first time posting on thescripts.com, and I'm in dire need of some help. All I want to do is disable the submit button (not the entire form) onClick, and am wondering if this is possible. Here's the current coding: <form enctype="multipart/form-data" action="?id=completeupload" name="submitform" method="POST"> <b>File to Upload:</b>&nbsp;<input name="userfile" size="50" type="file"><br><br> <span class="class3"> <input...
1
2571
by: sirdevo | last post by:
There is one combobox on a subform named Report Soil Series Subform1. The combobox is named cboSoilSeries. I need to disable this so the user can't enter values. I could also disable the whole subform since this is the only control on the subform. I've tried this line of code but it says you can't disable the control while it has focus. Forms!!.Form.cboSoilSeries.Enabled = False The combobox does not have focus when I run that line of...
4
2622
by: Pabicoch | last post by:
Ok so I'm trying to move items from one listbox to another by using multiple buttons i.e I have 2 buttons cmdRight and cmdRight2 which are both disabled on form load If the user selects a single item on the first listbox a cmdRIght button enables but cmdRight2 is still disabled , if the user selects multiple items on the first listbox a cmdRight2 button enables but cmdRight is disabled. I've got the move buttons to work but the problem...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10327
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10151
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.