Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


tom mcbain
Javascript DOM
0 Answer(s)      3 years and 11 months ago
Posted in : JavaScript Questions


I'm getting into client-side scripting using javascript.

I am attempting to build a football team fixture application. The user would able to enter the number and name of the teams and then applicaion would generate a fixture list. I was knocking about using DOM techniques but with minimal success. I used  a nested for loop for generating the fixture list but it's not would I'd like. I would like to generate the fixtures on a weekly basis.

I've included code for anyone to view and offer advice.

The following code is the HTML page.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/footballTemp.dwt" codeOutsideHTMLIsLocked="false" -->

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<!-- InstanceBeginEditable name="doctitle" -->

<title>Star Football</title>

<script language="javascript" type="text/javascript" src="selectTeamNo.js">

</script>



<!-- InstanceEndEditable -->

<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->

<link href="styles.css" rel="stylesheet" type="text/css" />

</head>



<body>



  <div id="logo">

    <img src="images/starfootball.png" alt="starFootballlogo" width="453" height="105" />

  </div>



<div id="menu"><a href="home.html">Home</a> | <a href="sponsorship.html">Sponsorship</a> | <a href="news.html">News</a> | <a href="weather.html">Weather</a><a href="#"></a> |  <a href="blogger.html">Blogger</a> | </div>

<div id="content"><!-- InstanceBeginEditable name="content" -->



<div id = "heading">Star Football League</div><br /><br />

     <div id = form1>   <form name="form1">

            <table width="380">

  <tr>

                    <td colspan="2" align="left"><b>Input Team</b>

                      <b>&nbsp;:</b>

                  <td width="276">

                <input type="text" name="name"/>                </tr>

                <tr>

                    <td width="82" align="right">

                  <td width="33">

              <td width="276">                </tr>

                <tr>

                    <td width="82" align="right">

                  <td width="33">

                  <td width="276">

                <input type="button" Value="Submit Team" 

                     onclick="insert(this.form.name.value),show();"/>

                <input type="button" Value="Fixtures" 

                     onclick="insert(this.form.name.value),show2();"/>

                    </tr>

            </table>

        </form>

        </div>

        <table width="561" height="62" border="2" bordercolor="#FFFFFF">

  <tr><td width="181" height="54" align="left" valign="top"> <div id="myDiv"></div></td>

  <td width="169"><div id="myDiv2"></div></td></tr></table>

<!-- InstanceEndEditable --></div>

<div id="footer">Copyright 2010 starfootball.com</div>

</body>

<!-- InstanceEnd --></html>

**//This is the javascript code I used from an external file**

var array = new Array();
   //Create new method/fuction
            function insert(val){
                array[array.length]=val;
            }
            function show() {
                var string="<b>These are the chosen teams :</b><br>";
                j = 8
    for(i = 0; i < 8; i++) {
                    string =string+array[i]+"<br>";
                }
                if(array.length > 0)
                 document.getElementById('myDiv').innerHTML = string  ;

            }



    var hometeam = new Array();
    var awayteam = new Array();
    function show2() 
       {
        var string
        hometeam = array
        awayteam = array
                var string2="<tr><td><b>Fixtures :</b><br></td></tr>";
                for(i = 0; i < 8; i++) {
     for(j = 1+i; j < 8; j++) {
      string2 =string2+hometeam[i]+" &nbsp;&nbsp; vs &nbsp;&nbsp;" +hometeam[j]+"  "+"<br>";
     }
                }


     if(hometeam.length > 0)
                 document.getElementById('myDiv2').innerHTML = string2  ;

            }

Advertisement
View Answers

Related Tutorials/Questions & Answers:
Javascript DOM
Javascript DOM  I'm getting into client-side scripting using javascript. I am attempting to build a football team fixture application. The user... generate a fixture list. I was knocking about using DOM techniques but with minimal
javascript dom error-message
javascript dom error-message  javascript dom error-message
Advertisements
DOM
DOM  hello, What is DOM?   hii, DOM is stands for Document object Model. DOM is an interface-oriented Application Programming Interface. We can use it for navigation of the entire document
DOM
DOM  package name for Document class?   Hi Friend, The package is known as dom api. For more information, visit the following links: http://www.roseindia.net/xml/ http://www.roseindia.net/xml/dom/ Thanks
DOM to SAX and SAX to DOM - XML
DOM SAX Parser Java  What is the Difference between SAX and DOM parsers
DOM to SAX and SAX to DOM - XML
Java DOM to SAX and SAX to DOM  Simple API for XML and Document Object Model
DOM - XML
DOM  Hi... I created an xml file through java by using DOM Now..I need to get the prompt for download when i clicked the button... I used downloadaction...for this But it didn't worked.. Its jus viewing the xml file
Dom in java
Dom in java  Exception in thread "main" org.w3c.dom.DOMException: INVALIDCHARACTERERR: An invalid or illegal XML character is specified... Create XML using DOM import java.io.*; import org.w3c.dom.*; import
DOM - XML
DOM  Hello.... I'm creating an xml file from java using DOM... from the database values... and saving it in a file But the created xml file is generating all its files in a single line.. But i need to get the next tag
dom to xml string
dom to xml string  Hi, I am writing a program in java that reads... have save the dom document into xml file. How to convert dom to xml string... for converting DOM object into string data. Please check the thread dom to xml
Java dom from string
Java dom from string  Hi, How to create dom tree from string data? I am trying to search the example for java dom from string. Thanks   Hi, Following code might be useful: import java.io.StringReader; import
Java-XML-DOM - XML
Java-XML-DOM  Hi! I need some help. I have to make java program that loads an xml file and from it builds DOM(later i will have to work with it - like using xpath in java find some value and replace it...). Since i'm new to java
Document Object Model(DOM)
to use DOM in order to render an HTML document. However, JavaScript scripts... Document Object Model(DOM)       The Document Object Model (DOM) is a an standard object model
DOM API - Java Beginners
DOM API  How can i go through each and every node of an xml file Each and everyChild? my xml file is given below: 810 32 141 22
DOM paring problem
DOM paring problem  Hi My code always show arrayindexoutofbound here is my code i am using arraylist to display and DOM parser to retrieve XML value. I am searching the value by attributes equals 2. this error i am getting
DOM paring problem
DOM paring problem  Hi My code always show arrayindexoutofbound here is my code i am using arraylist to display and DOM parser to retrieve XML value. I am searching the value by attributes equals 2. this error i am getting
DOM API - Java Beginners
DOM API  How can i go through each and every node of an xml file Each and everyChild? my xml file is given below...); } } } ---------------------------------------------- Read for more information. http://www.roseindia.net/xml/dom
JavaScript clearTimeOut method
JavaScript clearTimeOut method       JavaScript's HTML DOM window object method.... In this section of JavaScript methods tutorials we will be able to clear the set time out
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
Javascript
Javascript  How validations are done using javascript ,with example? and interview questions on javASCRIPT
Inserting content(DOM Insertion)
Inserting content(DOM Insertion)       Inserting content(DOM Insertion) Inserting Dom contents to html ,can be categories in the following 4 categories
DOM Parser Tutorial
DOM Parser Tutorial Introduction Dom stands for Document Object Model.... It is available in package org.w3c.dom. Dom is a cross-language API. It provides many... tree elements. With the help of Dom api, user  can add, delete
javaScript
javaScript  How to open a browser window that cannot be resized? (HTML + Javascript
javascript
javascript  write a program to display implement about browsers using javascript
javascript
javascript  Hi deepak, how to write form validation on javascript
JavaScript
JavaScript  how to get full path of a file type in 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  i have just learned javascript... can you tell me what kind of applications can be made by javascript?? thank you
Create an Empty DOM Document
Create an Empty DOM Document       This Example shows how to create an empty DOM Document . JAXP... documents. Here the Document BuilderFactory is used to create new DOM parsers
javascript
javascript  Hi sir, This is sinduri, i want to learn javascript, so plz can u help me.how to learn
Advertisements
 

 

 

DMCA.com