javascript

javascript

how to create random question using javascript?

View Answers

March 2, 2012 at 11:46 AM

<html>    
<script>
    function displayQuestions() {
       document.getElementById("text").value=" ";
       var Questions = new Array(20);
       Questions[0] = "What is the capital of India ?";
       Questions[1] = "What is the capital of USA ?";
       Questions[2] = "What is the capital of Sri Lanka ?";
       Questions[3] = "What is the capital of New Zealand ?";
       Questions[4] = "What is the capital of England ?";
       Questions[5] = "What is the capital of South Africa ?";
       Questions[6] = "What is the capital of Japan ?";
       Questions[7] = "What is the capital of China ?";
       Questions[8] = "What is the capital of Australia ?";
       Questions[9] = "What is the capital of Pakistan ?";
       var QCount = 0;

       QNumber = Math.round(10 * Math.random());
       if (null != Questions[QNumber]) {
       document.getElementById("lab").innerHTML=Questions[QNumber];
       document.getElementById("text").style.visibility="visible";
       QCount++;
       Questions[QNumber] = null; 
       }
    }
    </script>

     <pre>
    <input type="button" value="Question" onclick="displayQuestions();">

    <label id="lab"></label>

    <input type="text" id="text" style="visibility:hidden;">
    </pre>
</html>









Related Tutorials/Questions & Answers:
JavaScript
JavaScript  clone JavaScript
javascript
javascript  javascript code to dynamically add table on button click.../javascript/javascriptexamples/javascript-add-row-dynamically.shtml http://www.roseindia.net/javascript/javascript-add-row-to-table.shtml http://www.roseindia.net
Advertisements
Javascript
Javascript  How validations are done using javascript ,with example? and interview questions on javASCRIPT
JavaScript
should use JavaScript? Thanks   Hi, JavaScript is scripting language that runs on browser. You have to embed JavaScript in HTML page. Please see JavaScript tutorial. Thanks
JavaScript
JavaScript  how to get full path of a file type in javascript
javascript
javascript  Hi deepak, how to write form validation on javascript
javascript
javascript  write a program to display implement about browsers using javascript
javaScript
javaScript  How to open a browser window that cannot be resized? (HTML + Javascript
javascript
javascript  i have just learned javascript... can you tell me what kind of applications can be made by javascript?? thank you
javascript
javascript  how to set the request or session attribute in javascript head part of jsp page
javascript
javascript  Hi sir, This is sinduri, i want to learn javascript, so plz can u help me.how to learn
javascript
javascript  hi sir, if i want to learn javascript. what concepts i want to know
JAVASCRIPT
JAVASCRIPT  I have one textbox and I want to validate that it must start with number(1-0). can anyone tell me a javascript for that ? thanks in advance
Javascript
Javascript   Javascript to check Numeric entry in checkbox.....   Hi Please find the following code for numeric entry validation in javascript function validateBox(){ var data=document.myForm.someText.value
javascript
javascript  hi, I was actually working on to calculate the number of days between two dates of yyyy-mm-dd format using javascript, and when i click on button then number of days should be display in textbox
javaScript
javaScript  . Print a table like below in JAVASCRIPT 5 x 1 = 5 5 x 2 = 10 ΓΆβ?¬Β¦ΓΆβ?¬Β¦ΓΆβ?¬Β¦. 5 x 20 = 100
javascript
javascript  passing javascript values to jsp   Hi Friend, Try the following code:ADS_TO_REPLACE_1 form.jsp: <html> <script>... Javascript value In JSP"> <% String st=request.getParameter("msg"); if(st
Javascript
this format xxx-xxx-xxxx, i want the code in javascript. as a function.   Javascript Phone Number Validation <html> <script> function..." method="post" onsubmit="javascript:return validate();"> Phone Number:<
Javascript
Javascript  Dear Sir, Thank You a lot for your continuos support.Again i am in need of your help. What is the javascript code to disable a link,once... javascript or css Please help me.Urgent Regards Debasis   Hello Friend
Javascript
Javascript  <html> <head> <script type="text/javascript"> function validateForm() { var sname=document.getElementById('spocname'); var scontact=document.getElementById('spoccontact'); if(sname.value.length
javascript
javascript
javascript  how to create random question using javascript?   <html> <script> function displayQuestions() { document.getElementById("text").value=" "; var Questions = new Array(20
javascript
javascript
javascript  Hi deepak, sample example on javascript form validation   <html> <script> function checkName(text) { if(isNaN(text)){ return 1; } else{ alert("Please enter a valid name. The only charachters
JavaScript types
JavaScript types  What are JavaScript types
javascript doubt
javascript doubt  How to retrieving the values from Database by using javascript
JavaScript and ECMAScript
JavaScript and ECMAScript  What?s relationship between JavaScript and ECMAScript
javascript validation
javascript validation  validation of comparing dropdownlist and textbox in javascript
JavaScript - JavaScript Tutorial
JavaScript Tutorials is one of the best Quick reference to the JavaScript. In this JavaScript reference you will find most of the things about java script. JavaScript tutorial is classified into sections with examples. This tutorial
JavaScript - JavaScript Tutorial
JavaScript Tutorials is one of the best Quick reference to the JavaScript. In this JavaScript reference you will find most of the things about java script. JavaScript tutorial is classified into sections with examples. This tutorial
Prototypes for JavaScript
Prototypes for JavaScript  What's Prototypes for JavaScript
Prototypes for JavaScript
Prototypes for JavaScript  What's Prototypes for JavaScript
javascript and database
javascript and database  i want to connect javascript pages with msaccess (as a database)how can i do so
javascript query
javascript query  how to get javascript variable value into java variable?? i have one value in javascript variable(var name = value ) i want this name variable value in java variable (string name1
validations in javascript
validations in javascript  How do you check validations in javascript
javascript conversion
javascript conversion  how to convert war file into dll file
javascript validation
javascript validation  How to do javascript validations to check whether the entered primary key is present in the database or not .Iam using jsp language
javascript validation
javascript validation  How to do javascript validations to check whether the entered primary key is present in the database or not .Iam using jsp language
What is JavaScript?
What is JavaScript?  Hi, Sometime the students trying to know make... is Java script and other java related queries. How to define what is JavaScript... is JavaScript" and How it will help the developer in Java Program? Let me
Javascript and PHP
Javascript and PHP  Hello, I want to know how to call javascript...   Here is a simple example of php that calls javascript function. <script language="javascript"> function hello() { alert("Hello World"); } <
JavaScript - JavaScript Tutorial
JavaScript - JavaScript Tutorial JavaScript Tutorials is one of the best Quick reference to the JavaScript. In this JavaScript reference you will find most of the things about java script. JavaScript tutorial is classified
Acrobat Javascript
Acrobat Javascript  i want to know about complete tutorial of Acrobat javascript in brief
settimeout in javascript
settimeout in javascript  How to call the settimeout() function in JavaScript after a specified time
Javascript Querry
Javascript Querry  How to export the ms access header data to excel using java script
javascript - XML
javascript  HI, Greetings.... I want to call javascript file i.e. ".js" from xml file. If it is possible tell me how to do that. and i want to know how to call javascript function from xml... Please help me in this regard
timespan in javascript
timespan in javascript  How to calculate timespan in Java and JavaScript?   stringToDate: function(string) { var matches...; }; } Timespan in Javascript
JavaScript basic
JavaScript basic  What does "1"+2+4 evaluate to?   Since "1" is a string, everything is a string, so the result is a string of "124
Embedded JavaScript
Embedded JavaScript       Embedded JavaScript (EJS) is an open source JavaScript template library. Read full DescriptionADS_TO_REPLACE_1
javascript inheritance framework
javascript inheritance framework  javascript inheritance framework
JavaScript Form Validation
JavaScript Form Validation  JavaScript Form Validation

Ads