SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jun 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascripting for mobile web application

    I am currently developing a application for mobile web and i need help regarding my codes... i can't seem to figure out how to make it work, im new to javascript this is my first time developing with it. i need to output a xml file as a questionnaire and make the question branch to another question and to another depending on the answer to the question.

    here is my code:

    var xmlDoc=null;
    xmlDoc=document.implementation.createDocument("","",null);
    xmlDoc.async=false;
    xmlDoc.load("sample.xml");
    var x=xmlDoc.getElementsByTagName("question");



    questionstorage=new Array();
    choicestorage=new Array();
    var x=xmlDoc.getElementsByTagName("question");



    for (y = 0; y <x.length; y++) {
    questionstorage[y] = x[y].getElementsByTagName("text")[0].childNodes[0].nodeValue;

    }
    var i=0;
    output();


    function output(){
    document.write(questionstorage[i]);
    var j=0;

    document.write('<input type="radio" value="'+x[i].getElementsByTagName("choice")[0].childNodes[0].nodeValue+'" name="radio" onclick="check1()">');
    document.write(x[i].getElementsByTagName("choice")[0].childNodes[0].nodeValue);
    document.write('<input type="radio" value="'+x[i].getElementsByTagName("choice")[1].childNodes[0].nodeValue+'" name="radio" onclick="check2()">');
    document.write(x[i].getElementsByTagName("choice")[1].childNodes[0].nodeValue);


    document.write('<input type="button" value="Next" onclick="check()"');
    document.write(i);

    }

    function check1(){
    //document.write(q{i});
    i=xmlDoc.getElementsByTagName("question")[i].getAttribute("choice1");
    output();
    }
    function check2(){
    //document.write(q{i});
    i=xmlDoc.getElementsByTagName("question")[i].getAttribute("choice2");
    output();
    }

  2. #2
    SitePoint Zealot Mattinblack's Avatar
    Join Date
    May 2009
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well the bad news is that the browsers in mobile phones will not rund javascript or flash. So you are stuck with html and asp or php.


Bookmarks

Posting Permissions

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