Web Analytics Made Easy -
StatCounter Showing data from array - CodingForum

Announcement

Collapse
No announcement yet.

Showing data from array

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Showing data from array

    Hi there.. Currently I am having problems showing stored data in the array. The script here is simple all it does is takes the data from user and store's the data to the array. When the user clicks on the submit title button, the user would be able to see all the information that was keyed by him/her. The problem is in the function show! I know I can have document.write but i want to show all the data in the very same page and not in a new screen.

    <html>
    <head>
    <title>Web Development</title>

    <script language="javascript">
    var i=1,j=0,k=0,l=0;
    var title=new Array();
    var question=new Array();
    var answer=new Array();
    var opt1=new Array();
    var opt2=new Array();
    var acc=new Array();
    var mcq=new Array();

    function t(){

    mcq[0]=document.formtitle.mcqtitle.value;
    mcq[1]=document.formtitle.number.value;
    go();}

    function go(){

    if (i<=mcq[1]){
    var q2="Q";
    var q2_1=[i] +"<input type='text' name='question' size='20'><br>"
    var q3="Answer <input type='text' name='answer' size='20'><br>";
    var q4="Option1 <input type='text' name='opt1' size='20'><br>";
    var q5="Option2 <input type='text' name='opt2' size='20'><br>";
    var qs="MCQ TITLE:\t\t"+ mcq[0]+"<form name='myform'>"+q2+q2_1+q3+q4+q5+"</form><input type='button' value='Save Question' onclick='store()'><input type='button' value='Submit Title' onclick='show()'>";
    qst.innerHTML=qs;
    i++;
    }
    }

    function store(){

    question[j]=document.myform.question.value;
    answer[j]=document.myform.answer.value;
    opt1[j]=document.myform.opt1.value;
    opt2[j]=document.myform.opt2.value;

    acc[j]=question[j]+"<br>"+answer[j]+"<br>"+opt1[j]+"<br>"+opt2[j];
    go();
    j++;
    }
    function show(){
    while(k!=mcq[1]){
    ***PROBLEM HERE***
    k++;}
    }

    </script>

    </head>
    <body>
    <script language="javascript">
    <!--

    var sent1="<div id=qst>";
    var sent2="<form name='formtitle'>";
    var sent3="PLEASE ENTER THE MCQ TITLE INTO THE BOX <input type='text' name='mcqtitle' size='20'><br>";
    var sent4="ENTER THE NUMBER OF QUESTIONS <input type='text' name='number' size='2'>";
    var sent5="</form><input type='button' value='Start' onclick='t()'></form></div>";
    document.write(sent1+sent2+sent3+sent4+sent5);

    </script>
    </body>
    </html>
    Last edited by pacfusion; Aug 3, 2005, 12:29 AM.

  • #2
    before we get into the coding, are you using geocities?
    i'm only 12, gimme some slack

    Comment


    • #3
      No not gonna use geocities, the data is going to be send to a server. The submit button is the button where the data will be send to the server. But I am not going there yet as I have not learned the server part yet instead of showing the data entered by the user. Its a project!

      Comment

      Working...
      X