<form> <input type="button" onclick="alert('Correct!')"value="1st option"> </form> |
This is what you actually see. Click on the button and see what happens.
So, in order to create a multiple choice question, you just have to change the "value" of the button (that is what will appear on the button) and the message of the alert. For example:
What colour is Darth Vader's lightsaber?
Here is the code. Just change the options and the message of the alert to your needs.
<form>
<input type="button" onclick="alert('Right!')"value="A">First option
</form>
<form>
<input type="button" onclick="alert('Wrong')"value="B">Second option
</form>
<form>
<input type="button" onclick="alert('Wrong')"value="C">Third option
</form>
<form>
<input type="button" onclick="alert('Wrong')"value="D">Fourth option
</form>
This is what you will see in your browser:
I think it is safe to say that all Internet browsers now sopport JavaScript. The only problem with it is that some users may chose to disable it in their browsers. In that case, your code won't work.


No comments:
Post a Comment