Results 1 to 3 of 3

Thread: Converting this to JavaScript/HTML

  1. #1

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765

    Converting this to JavaScript/HTML

    Ok, I wrote a VERY simple program in VB which I was hoping to turn into a Web kinda game.

    Basically it has 3 Buttons and a 2 Labels. Each Button has caption which is a Number ie 1 6 8

    In the first Label there is some Text like, click on the Number 1. And the final label is where text appears to tell them if they got it right or not.

    (Yes the program is for little kids)

    Making this in VB is piss easy, but I'm not really familar with JavaScript soo it anyone knows how to do this;

    Add Three Buttons to a WebPage, and on Clicked, it checks to see if its Caption = the Number in the "Click on the Number *:"

    Is it possible to print the text like in a Label in VB???

    I've attached an example if you don't understand my explanation.

    Thanks in Advance
    Attached Files Attached Files
    Don't Rate my posts.

  2. #2
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    Hi,

    I cant look at your VB project from here because I dont have VB on my PC here but is it something like this?

    Code:
    <html>
    <head>
    <title>Questions</title>
    <script language="JavaScript" type="text/javascript">
    <!--
    var que = new Array;  // array of questions
    que[0]=1;  // Questions.  When questions are displayed 'Press Number ' is displayed too
    que[1]=2;
    que[2]=3;
    
    var que_num = 0;  // questions number item (start at questions 1 which is 0 in array)
    
    function startQuestions(){
    frm = document.form1;  // name of form
    frm.question.value='Press Number ' + que[que_num];
    }
    
    function checkAnswer(objectID){
    frm = document.form1;  // name of form
    if (objectID.value==que[que_num]){
    	 frm.answer.value='This is correct!';
    	 que_num+=1; //move to next question
    	 if (que_num>=que.length){que_num=0;} // If question number is bigger than max of array then start again
    	 startQuestions();
    }else{
    	 frm.answer.value='Not Correct, Try Again!';
    }
    }
    //-->
    </script>
    </head>
    <body onload="startQuestions()">
    <form name="form1">
      <input type="button" name="button1" value="1" onclick="checkAnswer(this)">
      <input type="button" name="button2" value="2" onclick="checkAnswer(this)">
      <input type="button" name="button3" value="3" onclick="checkAnswer(this)"><br><br>
      Question : <input type="text" name="question" readonly="true"><br>
      Result : <input type="text" name="answer" readonly="true"><br>
    </form>
    </body>
    </html>
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  3. #3

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Yep, thats about it. Thanks.
    Don't Rate my posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width