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) -
<html>
-
<head>
-
</head>
-
<script language="javascript">
-
alert("Are you sure you want to play this game?");
-
var Name = prompt("What is your name?");
-
</script>
-
-
<script type="text/javascript">
-
document.write(Name);
-
</script>
-
-
<center><button id="button1" onClick="start()">First Question</button></center>
-
-
<script>
-
function start() {
-
var one = prompt("What is 3 * 4 ?");
-
-
if (one!=12)
-
{
-
{
-
alert("Correct");
-
}
-
else
-
{
-
alert("Incorrect");
-
}
-
}
-
</script>
-
</html>
-
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
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 - document.getElementById()
. Thank you for the help on my code. Oh and the - 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.
Dormilich 8,658
Recognized Expert Moderator Expert
was when i was trying to figure out how to delete a button
simple enough: - // or whatever you like to reference the button
-
var button = document.getElementById("theButton");
-
-
button.parentNode.removeChild(button);
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.
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.
I'm going to try to keep the code UTD as much as i can on here. -
<!DOCTYPE html>
-
<html>
-
<head>
-
</head>
-
<script type="text/javascript">
-
var w= confirm("Are you sure you want to play this game?");
-
-
if (w==true)
-
{
-
var button = document.getElementById("theButton");
-
-
button.parentNode.removeChild(button);
-
}
-
else
-
{
-
window.close();
-
}
-
</script>
-
<script type="text/javascript">
-
var Name = prompt("What is your name?");
-
</script>
-
-
<script type="text/javascript">
-
document.write(Name);
-
</script>
-
-
<center><button id="button1" onClick="start()">First Question</button></center>
-
-
<script type="text/javascript">
-
function start() {
-
var one = prompt("What is 3 * 4 ?");
-
-
if (one!=12)
-
{
-
{
-
alert("Correct");
-
}
-
else
-
{
-
alert("Incorrect");
-
}
-
}
-
</script>
-
</html>
-
Dormilich 8,658
Recognized Expert Moderator Expert
I would disable the buttons rather than removing ...
anyways, your if/else is still wrong. - // with appropriate indenting
-
if (...)
-
{
-
{
-
alert(...);
-
}
-
else
-
{
-
alert(...);
-
}
-
}
I’m pretty sure that throws an unexpected "else" error.
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.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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+
|
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...
|
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...
|
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?
|
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...
| |
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();
|
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
|
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> <input name="userfile" size="50" type="file"><br><br>
<span class="class3">
<input...
|
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...
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
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...
|
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();...
|
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...
| |
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
|
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...
| |